@@ -95,7 +95,13 @@ private static NavigableSet<DocValuesMultiRangeQuery.LongRange> resolveOverlaps(
95
95
new PriorityQueue <>(clauses .size () * 2 ) {
96
96
@ Override
97
97
protected boolean lessThan (Edge a , Edge b ) {
98
- return a .getValue () - b .getValue () < 0 ;
98
+ if (a .getValue () < b .getValue ()) {
99
+ return true ;
100
+ } else if (a .getValue () == b .getValue ()) {
101
+ return a .point ; // if a point is in the edge of the range, pass the point first
102
+ } else {
103
+ return false ;
104
+ }
99
105
}
100
106
};
101
107
for (DocValuesMultiRangeQuery .LongRange r : clauses ) {
@@ -115,7 +121,7 @@ protected boolean lessThan(Edge a, Edge b) {
115
121
for (int i = 0 ; i < totalEdges ; i ++) {
116
122
Edge smallest = heap .pop ();
117
123
if (depth == 0 && smallest .point ) {
118
- if (i < totalEdges - 1 && heap . top (). point ) { // repeating same points
124
+ if (i < totalEdges - 1 ) { // the point sits on the edge of the range
119
125
if (smallest .getValue () == heap .top ().getValue ()) {
120
126
continue ;
121
127
}
@@ -131,11 +137,13 @@ protected boolean lessThan(Edge a, Edge b) {
131
137
} else {
132
138
depth --;
133
139
if (depth == 0 ) {
134
- sortedClauses . add (
140
+ DocValuesMultiRangeQuery . LongRange range =
135
141
started .range == smallest .range // no overlap case, the most often
136
142
? smallest .range
137
143
: new DocValuesMultiRangeQuery .LongRange (
138
- started .getValue (), smallest .getValue ()));
144
+ started .getValue (), smallest .getValue ());
145
+ boolean strictlyIncreasing = sortedClauses .add (range );
146
+ assert strictlyIncreasing ;
139
147
started = null ;
140
148
}
141
149
}
0 commit comments