Skip to content

Apache Lucene open-source search software

Use LessThan here rather than Comparator (#14871)

Simon Coopercd27603950d0
diff --git a/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java b/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java
index 115b227bbd8..ec8b5c28c3d 100644
--- a/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java
+++ b/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java
@@ -18,7 +18,6 @@ package org.apache.lucene.search;
import java.io.IOException;
import java.util.Collection;
-import java.util.Comparator;
import org.apache.lucene.internal.hppc.LongArrayList;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.FixedBitSet;
@@ -73,10 +72,8 @@ final class BooleanScorer extends BulkScorer {
}
this.leads = new DisiWrapper[scorers.size()];
this.head =
- PriorityQueue.usingComparator(
- scorers.size() - minShouldMatch + 1, Comparator.comparingInt(d -> d.doc));
- this.tail =
- PriorityQueue.usingComparator(minShouldMatch - 1, Comparator.comparingLong(d -> d.cost));
+ PriorityQueue.usingLessThan(scorers.size() - minShouldMatch + 1, (a, b) -> a.doc < b.doc);
+ this.tail = PriorityQueue.usingLessThan(minShouldMatch - 1, (a, b) -> a.cost < b.cost);
this.minShouldMatch = minShouldMatch;
this.needsScores = needsScores;
LongArrayList costs = new LongArrayList(scorers.size());
diff --git a/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java b/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java
index 866528dbee6..6318cac5276 100644
--- a/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java
+++ b/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java
@@ -18,7 +18,6 @@ package org.apache.lucene.search.comparators;
import java.io.IOException;
import java.util.ArrayDeque;
-import java.util.Comparator;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexOptions;
@@ -596,7 +595,7 @@ public class TermOrdValComparator extends FieldComparator<BytesRef> {
}
}
disjunction =
- PriorityQueue.usingComparator(size, Comparator.comparingInt(p -> p.postings.docID()));
+ PriorityQueue.usingLessThan(size, (a, b) -> a.postings.docID() < b.postings.docID());
disjunction.addAll(postings);
}
}