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

A few small tweaks to VectorUtil#findNextGEQ #13972

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

gsmiller
Copy link
Contributor

@gsmiller gsmiller commented Nov 1, 2024

  1. Rearrange/rename the parameters to be more idiomatic (e.g., follow conventions of Arrays#... methods)
  2. Add assert to ensure expected sortedness we may rely on in the future (so we're not trappy)
  3. Migrate PostingsReader to call VectorUtil instead of VectorUtilSupport (so it benefits from the common assert)

1. Rearrange/rename the parameters to be more idiomatic (e.g., follow conventions of Arrays#... methods)
2. Add assert to ensure expected sortedness we may rely on in the future (so we're not trappy)
3. Migrate PostingsReader to call VectorUtil instead of VectorUtilSupport (so it benefits from the common assert)
@gsmiller gsmiller requested a review from jpountz November 1, 2024 16:33
@@ -1755,13 +1755,13 @@ static long readVLong15(DataInput in) throws IOException {
}
}

private static int findNextGEQ(long[] buffer, int length, long target, int from) {
for (int i = from; i < length; ++i) {
private static int findNextGEQ(long[] buffer, long target, int from, int to) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this change for consistency but don't have any strong feelings about it. If there's a preference to just leave it be, I'm fine reverting this file.

@@ -601,7 +599,7 @@ public int advance(int target) throws IOException {
}
}

int next = VECTOR_SUPPORT.findNextGEQ(docBuffer, docBufferSize, target, docBufferUpto);
int next = VectorUtil.findNextGEQ(docBuffer, target, docBufferUpto, docBufferSize);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jpountz I made this change so that everything goes through VectorUtil and the assert. It also seemed a little more consistent with how we leverage VectorUtil vs. VectorUtilSupport elsewhere, but I'm not sure if you had a good reason for writing it the way you did. If there's a performance (or other) consideration here, I'd be happy to understand that better.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did it this way after doing something similar with PostingDecodingUtil, which didn't really belong to VectorUtil. I agree it's nicer the way you did it, I would not expect performance implications if inlining works properly, nightly benchmarks will tell us.

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

Thank you!

@@ -601,7 +599,7 @@ public int advance(int target) throws IOException {
}
}

int next = VECTOR_SUPPORT.findNextGEQ(docBuffer, docBufferSize, target, docBufferUpto);
int next = VectorUtil.findNextGEQ(docBuffer, target, docBufferUpto, docBufferSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

I did it this way after doing something similar with PostingDecodingUtil, which didn't really belong to VectorUtil. I agree it's nicer the way you did it, I would not expect performance implications if inlining works properly, nightly benchmarks will tell us.

@gsmiller gsmiller merged commit a3d56ea into apache:main Nov 5, 2024
3 checks passed
@gsmiller gsmiller deleted the findNextGEQ-tweaks branch November 5, 2024 00:09
gsmiller added a commit that referenced this pull request Nov 5, 2024
1. Rearrange/rename the parameters to be more idiomatic (e.g., follow conventions of Arrays#... methods)
2. Add assert to ensure expected sortedness we may rely on in the future (so we're not trappy)
3. Migrate PostingsReader to call VectorUtil instead of VectorUtilSupport (so it benefits from the common assert)
@gsmiller gsmiller added this to the 10.1.0 milestone Nov 5, 2024
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.

2 participants