NightOwl888 commented on code in PR #1067: URL: https://github.com/apache/lucenenet/pull/1067#discussion_r1891072246
########## src/Lucene.Net/Util/Packed/gen_Packed64SingleBlock.py: ########## @@ -0,0 +1,338 @@ +#! /usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ## LUCENENET PORTING NOTES +# This script was originally written for Python 2, but has been tested against Python 3. +# No changes were necessary to run this script in Python 3. + +SUPPORTED_BITS_PER_VALUE = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16, 21, 32] + +HEADER="""using Lucene.Net.Diagnostics; +using Lucene.Net.Support; +using System; +using System.Runtime.CompilerServices; + +// This file has been automatically generated, DO NOT EDIT Review Comment: Maybe we should make this message more prominent and indicate how to generate the file so one doesn't have to search if they see the message. ```c# //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by the gen_Packed64SingleBlock.py script. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ ``` ########## src/Lucene.Net/Util/Packed/gen_PackedThreeBlocks.py: ########## @@ -0,0 +1,192 @@ +#! /usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ## LUCENENET PORTING NOTES +# This script was originally written for Python 2, but has been tested against Python 3. +# No changes were necessary to run this script in Python 3. + +HEADER="""using Lucene.Net.Diagnostics; +using Lucene.Net.Support; +using System; +using System.Runtime.CompilerServices; + +// This file has been automatically generated, DO NOT EDIT Review Comment: Maybe we should make this message more prominent and indicate how to generate the file so one doesn't have to search if they see the message. ```c# //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by the gen_PackedThreeBlocks.py script. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ ``` ########## src/Lucene.Net/Util/Packed/gen_Direct.py: ########## @@ -0,0 +1,224 @@ +#! /usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ## LUCENENET PORTING NOTES +# This script was originally written for Python 2, but has been tested against Python 3. +# No changes were necessary to run this script in Python 3. + +# LUCENENET specific - we write the usings before the header +HEADER="""// This file has been automatically generated, DO NOT EDIT Review Comment: Maybe we should make this message more prominent and indicate how to generate the file so one doesn't have to search if they see the message. ```c# //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by the gen_Direct.py script. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ ``` ########## src/Lucene.Net/Util/Packed/gen_BulkOperation.py: ########## @@ -0,0 +1,414 @@ +#! /usr/bin/env python + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ## LUCENENET PORTING NOTES +# This script was originally written for Python 2, but has been modified to work with Python 3. +# It is noted below where changes were made to support Python 3. +# Some of the changes have been backported from newer versions of Lucene, +# so when upgrading this script in the future, feel free to remove those comments. + +# LUCENENET backport - Python 3 support (lucene 945b1cb) +try: + # python 3.9+ + from math import gcd +except ImportError: + # old python + from fractions import gcd + +"""Code generation for bulk operations""" + +MAX_SPECIALIZED_BITS_PER_VALUE = 24 +PACKED_64_SINGLE_BLOCK_BPV = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 16, 21, 32] +OUTPUT_FILE = "BulkOperation.cs" + +# LUCENENET specific - we write the usings before the header, since +# the numbered files don't need them +HEADER = """// This file has been automatically generated, DO NOT EDIT Review Comment: Maybe we should make this message more prominent and indicate how to generate the file so one doesn't have to search if they see the message. ```c# //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by the gen_BulkOperation.py script. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ ``` ########## src/Lucene.Net/Util/Packed/README.md: ########## @@ -0,0 +1,28 @@ +# Lucene.Net.Util.Packed + +## Generating the files + +There are four Python scripts in this folder: +[`gen_BulkOperation.py`](gen_BulkOperation.py), +[`gen_Direct.py`](gen_Direct.py), +[`gen_Packed64SingleBlock.py`](gen_Packed64SingleBlock.py), and +[`gen_PackedThreeBlocks.py`](gen_PackedThreeBlocks.py). +These scripts were ported from the original Lucene 4.8.1 code, and modified to generate the corresponding C# code instead of Java. + +To generate the files, run the following commands from this directory: Review Comment: While this documentation is useful to have, what is preventing us from adding these scripts to the build as was the case in Lucene? https://github.com/apache/lucene/blob/releases/lucene-solr/4.8.1/lucene/core/build.xml#L101-L127 Granted, we would need to add a Python3 dependency to Visual Studio, command line, and CI builds, but that doesn't seem like such a big deal. We would need a separate PR to update the main README so it can be applied after this is released. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org