-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Convert more PriorityQueues to use Comparator #14761
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
base: main
Are you sure you want to change the base?
Conversation
This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR. |
class SpanPositionQueue extends PriorityQueue<Spans> { | ||
SpanPositionQueue(int maxSize) { | ||
super(maxSize); // do not prepopulate | ||
public interface FloatComparator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no JCL methods to compare floats without converting them to doubles first, so this enables direct float comparisons. The interface compare
method isn't actually used here, but it seems remiss to not have a FloatComparator
interface without a compare
method defined.
This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR. |
This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR. |
@@ -92,7 +93,22 @@ public SloppyPhraseMatcher( | |||
this.slop = slop; | |||
this.numPostings = postings.length; | |||
this.captureLeadMatch = captureLeadMatch; | |||
pq = new PhraseQueue(postings.length); | |||
pq = | |||
PriorityQueue.usingLessThan( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing this to a Comparator
did have an effect on performance, so keeping with the lessThan
implementation here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this change! I've wanted to do this for years.
This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR. |
63eff0b
to
5765b34
Compare
This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR. |
Following on from #14705, convert some more
PriorityQueue
s to use Comparator. This still leaves several complicated and public API subclasses ofPriorityQueue