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

Cleanup XorPlus8 + guard against infinite loop in table construction #30

Merged
merged 4 commits into from
Oct 15, 2021

Conversation

steve-scalyr
Copy link
Contributor

This PR contains some minor changes to the XorPlus8 class:

  • Update / clarify a few comments.
  • More consistent use of this. when assigning instance fields in constructor
  • Round the table length down to a multiple of 3, as any additional entries are wasted
  • More consistent computation of bitCount; remove an unused constructor that was assigning it incorrectly
  • Guard against infinite loops during table construction (could be caused by code bugs or bad input)

Regarding the unused constructor that I removed: it did not populate seed or rank, and I believe the latter means that any attempt to use the instance created by this constructor would have resulted in NullPointerException.

The changes are small, but can most easily be reviewed one commit at a time.

@steve-scalyr
Copy link
Contributor Author

@thomasmueller could you take a look? This PR contains the infinite loop guard proposed in the discussion of #30. I also took the opportunity to read through the code to make sure I understood all of it, and along the way I made a few other small changes.

@@ -110,7 +102,6 @@ public XorPlus8(int size, byte[] fingerprints) {
public XorPlus8(long[] keys) {
this.size = keys.length;
this.arrayLength = getArrayLength(size);
this.bitCount = arrayLength * BITS_PER_FINGERPRINT;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This value is never read; a new value is written near the end of the method.

Copy link
Contributor

@thomasmueller thomasmueller left a comment

Choose a reason for hiding this comment

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

Very good improvement! Thanks a lot!

@thomasmueller thomasmueller merged commit f5f4a07 into FastFilter:master Oct 15, 2021
@steve-scalyr
Copy link
Contributor Author

Thanks!

One last request: would it be possible to publish a new release (1.0.3) now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants