Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ Optimizations

Bug Fixes
---------------------
(No changes)

* GITHUB#16295: SingletonSortedNumericDocValues now delegates rangeIntoBitSet
to the wrapped NumericDocValues, enabling optimized range evaluation for
single-valued sorted numeric fields. (Costin Leau)

Other
---------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ public int docIDRunEnd() throws IOException {
return in.docIDRunEnd();
}

@Override
public void rangeIntoBitSet(
int fromDoc, int toDoc, long minValue, long maxValue, FixedBitSet bitSet, int offset)
throws IOException {
in.rangeIntoBitSet(fromDoc, toDoc, minValue, maxValue, bitSet, offset);
}

@Override
public long cost() {
return in.cost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,4 +694,43 @@ private void doTestSortedNumericRangeIntoBitSet(boolean dense, boolean fixedCard
}
}
}

public void testSingletonDelegatesRangeIntoBitSet() throws Exception {
int numDocs = 4096 * 4;
try (Directory dir = newDirectory()) {
IndexWriterConfig conf = new IndexWriterConfig();
conf.setCodec(new Lucene104Codec());
try (IndexWriter writer = new IndexWriter(dir, conf)) {
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
long value = i % 100;
doc.add(NumericDocValuesField.indexedField("numeric", value));
doc.add(SortedNumericDocValuesField.indexedField("sorted_numeric", value));
writer.addDocument(doc);
}
writer.forceMerge(1);
}
try (DirectoryReader reader = DirectoryReader.open(dir)) {
for (LeafReaderContext ctx : reader.leaves()) {
int maxDoc = ctx.reader().maxDoc();

FixedBitSet fromNumeric = new FixedBitSet(maxDoc);
ctx.reader()
.getNumericDocValues("numeric")
.rangeIntoBitSet(0, maxDoc, 20, 40, fromNumeric, 0);

FixedBitSet fromSingleton = new FixedBitSet(maxDoc);
ctx.reader()
.getSortedNumericDocValues("sorted_numeric")
.rangeIntoBitSet(0, maxDoc, 20, 40, fromSingleton, 0);

assertEquals(
"Singleton sorted numeric should produce identical results to underlying numeric",
fromNumeric,
fromSingleton);
assertTrue("Expected some bits set", fromNumeric.cardinality() > 0);
}
}
}
}
}
Loading