Apache Lucene open-source search software
fix TestSortedDvMultiRangeQuery.testDuelWithStandardDisjunction when … (#14632)
Mikhail Khludnev48016e09a032
diff --git a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/SortedNumericDocValuesMultiRangeQuery.java b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/SortedNumericDocValuesMultiRangeQuery.javaindex 0412e594db7..cc91d1f9a58 100644--- a/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/SortedNumericDocValuesMultiRangeQuery.java+++ b/lucene/sandbox/src/java/org/apache/lucene/sandbox/search/SortedNumericDocValuesMultiRangeQuery.java@@ -95,7 +95,13 @@ public class SortedNumericDocValuesMultiRangeQuery extends Query {new PriorityQueue<>(clauses.size() * 2) {@Overrideprotected boolean lessThan(Edge a, Edge b) {- return a.getValue() - b.getValue() < 0;+ if (a.getValue() < b.getValue()) {+ return true;+ } else if (a.getValue() == b.getValue()) {+ return a.point; // if a point is in the edge of the range, pass the point first+ } else {+ return false;+ }}};for (DocValuesMultiRangeQuery.LongRange r : clauses) {@@ -115,7 +121,7 @@ public class SortedNumericDocValuesMultiRangeQuery extends Query {for (int i = 0; i < totalEdges; i++) {Edge smallest = heap.pop();if (depth == 0 && smallest.point) {- if (i < totalEdges - 1 && heap.top().point) { // repeating same points+ if (i < totalEdges - 1) { // the point sits on the edge of the rangeif (smallest.getValue() == heap.top().getValue()) {continue;}@@ -131,11 +137,13 @@ public class SortedNumericDocValuesMultiRangeQuery extends Query {} else {depth--;if (depth == 0) {- sortedClauses.add(+ DocValuesMultiRangeQuery.LongRange range =started.range == smallest.range // no overlap case, the most often? smallest.range: new DocValuesMultiRangeQuery.LongRange(- started.getValue(), smallest.getValue()));+ started.getValue(), smallest.getValue());+ boolean strictlyIncreasing = sortedClauses.add(range);+ assert strictlyIncreasing;started = null;}}diff --git a/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestSortedDvMultiRangeQuery.java b/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestSortedDvMultiRangeQuery.javaindex 1cd0e561d75..1546b0d23d0 100644--- a/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestSortedDvMultiRangeQuery.java+++ b/lucene/sandbox/src/test/org/apache/lucene/sandbox/search/TestSortedDvMultiRangeQuery.java@@ -226,6 +226,17 @@ public class TestSortedDvMultiRangeQuery extends LuceneTestCase {int lower = ends[pos];int upper = ends[pos + 1];b.add(lower, upper);+ for (int repeat = 0; repeat < random().nextInt(3); repeat++) {+ if (rarely()) {+ b.add(lower, upper); // plain repeat+ } else {+ if (random().nextBoolean()) {+ b.add(lower, lower); // lower point repeat+ } else {+ b.add(upper, upper); // upper point repeat+ }+ }+ }}return b;}