Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Packed Producing Python Programs, #1008 #1067

Merged
merged 10 commits into from
Dec 22, 2024

Conversation

paulirwin
Copy link
Contributor

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a change, please open an issue to discuss the change or find an existing issue.

Ports the Python scripts for generating the various Lucene.Net.Util.Packed files.

Fixes #1008

Description

This ports the four Python scripts in the Packed package/namespace that generate the various files there, and updates them to produce C# code instead, as well as updates them to be compatible with Python 3 (as Python 2, which was used at the time, is now very out of support). This results in some minor syntax differences in the generated code. The README.md file in this folder explains how to run the scripts (which is simply to run them with Python 3, no virtual environment or dependencies needed).

Having these scripts ported will help us ensure that the code is being generated the same way as in Java, as well as to assist any necessary future changes to how the files are generated. It also just helps complete our 1:1 port of the Lucene code, be it Java or Python.

This also corrects an out-of-date type name in the package.md documentation for this namespace.

@paulirwin paulirwin added the notes:improvement An enhancement to an existing feature label Dec 17, 2024
@paulirwin
Copy link
Contributor Author

paulirwin commented Dec 17, 2024

This diff is larger than I'd like it to be, so I'm going to update the scripts to deviate from Lucene's whitespace style to make the diff smaller and easier to review. (edit: this is done)

@paulirwin paulirwin marked this pull request as ready for review December 17, 2024 18:30
src/Lucene.Net/Util/Packed/gen_PackedThreeBlocks.py Outdated Show resolved Hide resolved
src/Lucene.Net/Util/Packed/gen_Packed64SingleBlock.py Outdated Show resolved Hide resolved
src/Lucene.Net/Util/Packed/gen_Direct.py Outdated Show resolved Hide resolved
src/Lucene.Net/Util/Packed/gen_BulkOperation.py Outdated Show resolved Hide resolved
src/Lucene.Net/Util/Packed/README.md Show resolved Hide resolved
@paulirwin paulirwin marked this pull request as draft December 19, 2024 05:05
@paulirwin paulirwin marked this pull request as ready for review December 21, 2024 03:52
Copy link
Contributor

@NightOwl888 NightOwl888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks pretty good.

I have a couple of minor nit-picky things, but I will leave it up to you whether we should actually change them.

  1. The name of the workflow Lucene-Net-Packed-Python-Scripts.yml doesn't reflect the namespace where packed is (Util).
  2. In the IDE, it is more obvious that a file is generated by giving it a special name than having to rely on scrolling to the top of the file to see a warning that it is generated. In ICU4N, we are using the convention .generated.cs as a suffix for generated code. The tradeoff here is that we are also using a convention of keeping the file names 1-to-1 with the Java file names so it is easy to compare them lexographicallly in File Explorer so we can quickly tell when we have differences. Using the former approach may affect the latter to some extent, but I think it is something we can deal with (especially being that they are generated).

@paulirwin
Copy link
Contributor Author

I'm renaming the GitHub workflow file. I think we should keep the current names because it more closely matches the Java file names. This can always be revisited later in a separate PR if desired.

@paulirwin paulirwin merged commit 85c0141 into apache:master Dec 22, 2024
268 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes:improvement An enhancement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate C# code for Lucene.Net.Util.Packed types
2 participants