Skip to content

Commit fe2874b

Browse files
committed
Implement docIDRunEnd on new DocValues implementations; fix expectations in range query rewrites
1 parent a447aee commit fe2874b

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

server/src/main/java/org/elasticsearch/index/codec/tsdb/es819/ES819TSDBDocValuesProducer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,11 @@ long lookAheadValueAt(int targetDoc) throws IOException {
13041304
public long longValue() throws IOException {
13051305
return 0L; // Only one ordinal!
13061306
}
1307+
1308+
@Override
1309+
public int docIDRunEnd() throws IOException {
1310+
return disi.docIDRunEnd();
1311+
}
13071312
};
13081313
}
13091314
} else if (entry.sortedOrdinals != null) {
@@ -1326,6 +1331,11 @@ long lookAheadValueAt(int targetDoc) {
13261331
public long longValue() {
13271332
return ordinalsReader.readValueAndAdvance(doc);
13281333
}
1334+
1335+
@Override
1336+
public int docIDRunEnd() throws IOException {
1337+
return maxDoc;
1338+
}
13291339
};
13301340
} else {
13311341
final var disi = new IndexedDISI(

server/src/test/java/org/elasticsearch/index/codec/tsdb/es819/ES819TSDBDocValuesFormatTests.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
import org.apache.lucene.search.SortField;
3535
import org.apache.lucene.search.SortedNumericSortField;
3636
import org.apache.lucene.store.Directory;
37-
import org.apache.lucene.tests.util.TestUtil;
3837
import org.apache.lucene.util.BytesRef;
3938
import org.elasticsearch.cluster.metadata.DataStream;
4039
import org.elasticsearch.common.Randomness;
4140
import org.elasticsearch.common.lucene.BytesRefs;
4241
import org.elasticsearch.common.util.CollectionUtils;
4342
import org.elasticsearch.index.codec.Elasticsearch900Lucene101Codec;
43+
import org.elasticsearch.index.codec.Elasticsearch92Lucene103Codec;
4444
import org.elasticsearch.index.codec.tsdb.ES87TSDBDocValuesFormatTests;
4545
import org.elasticsearch.index.codec.tsdb.es819.ES819TSDBDocValuesProducer.BaseDenseNumericValues;
4646
import org.elasticsearch.index.codec.tsdb.es819.ES819TSDBDocValuesProducer.BaseSortedDocValues;
@@ -66,10 +66,7 @@
6666

6767
public class ES819TSDBDocValuesFormatTests extends ES87TSDBDocValuesFormatTests {
6868

69-
<<<<<<< HEAD
70-
final Codec codec = TestUtil.alwaysDocValuesFormat(new ES819TSDBDocValuesFormat());
71-
=======
72-
private final Codec codec = new Elasticsearch900Lucene101Codec() {
69+
private final Codec codec = new Elasticsearch92Lucene103Codec() {
7370

7471
final ES819TSDBDocValuesFormat docValuesFormat = new ES819TSDBDocValuesFormat(
7572
ESTestCase.randomIntBetween(1, 4096),
@@ -82,7 +79,6 @@ public DocValuesFormat getDocValuesFormatForField(String field) {
8279
return docValuesFormat;
8380
}
8481
};
85-
>>>>>>> origin/main
8682

8783
@Override
8884
protected Codec getCodec() {

server/src/test/java/org/elasticsearch/index/mapper/DateFieldTypeTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public void testRangeQuery() throws IOException {
376376
Query expected2 = SortedNumericDocValuesField.newSlowRangeQuery("field", instant1, instant2);
377377
assertEquals(
378378
expected2,
379-
ft2.rangeQuery(date1, date2, true, true, null, null, null, context).rewrite(newSearcher(new MultiReader()))
379+
ft2.rangeQuery(date1, date2, true, true, null, null, null, context)
380380
);
381381

382382
instant1 = nowInMillis;
@@ -419,7 +419,7 @@ public void testRangeQuerySubseconds() throws IOException {
419419
Query expected2 = SortedNumericDocValuesField.newSlowRangeQuery("field", instant1, instant2);
420420
assertEquals(
421421
expected2,
422-
ft2.rangeQuery(date1, date2, true, true, null, null, null, context).rewrite(newSearcher(new MultiReader()))
422+
ft2.rangeQuery(date1, date2, true, true, null, null, null, context)
423423
);
424424

425425
instant1 = nowInMillis;
@@ -459,7 +459,7 @@ public void testRangeQueryMillis() throws IOException {
459459

460460
DateFieldType ft2 = new DateFieldType("field", false);
461461
Query expected2 = SortedNumericDocValuesField.newSlowRangeQuery("field", instant1, instant2);
462-
assertEquals(expected2, ft2.rangeQuery(instant1, instant2, true, true, context).rewrite(newSearcher(new MultiReader())));
462+
assertEquals(expected2, ft2.rangeQuery(instant1, instant2, true, true, context));
463463

464464
assertIndexUnsearchable(
465465
Resolution.MILLISECONDS,
@@ -487,7 +487,7 @@ public void testRangeQueryNanos() throws IOException {
487487
Query expected2 = SortedNumericDocValuesField.newSlowRangeQuery("field", instant1, instant2);
488488
assertEquals(
489489
expected2,
490-
ft2.rangeQuery(date1, date2, true, true, null, null, null, context).rewrite(newSearcher(new MultiReader()))
490+
ft2.rangeQuery(date1, date2, true, true, null, null, null, context)
491491
);
492492

493493
assertIndexUnsearchable(Resolution.NANOSECONDS, (unsearchable) -> unsearchable.rangeQuery(instant1, instant2, true, true, context));

0 commit comments

Comments
 (0)