neoremind commented on code in PR #16285:
URL: https://github.com/apache/lucene/pull/16285#discussion_r3505176438
##########
lucene/core/src/test/org/apache/lucene/search/TestSkipBlockRangeIteratorIntoBitSet.java:
##########
@@ -694,4 +694,151 @@ private void doTestSortedNumericRangeIntoBitSet(boolean
dense, boolean fixedCard
}
}
}
+
+ /** Tests rangeIntoBitSet on GCD-encoded sorted numeric doc values with
fixed cardinality. */
+ public void testSortedNumericGcdEncodedRangeIntoBitSet() throws Exception {
+ doTestSortedNumericGcdRangeIntoBitSet(true, 3, 7, 1_000_000L);
+ }
+
+ /** Tests rangeIntoBitSet on delta-only encoded sorted numeric doc values. */
+ public void testSortedNumericDeltaOnlyRangeIntoBitSet() throws Exception {
+ doTestSortedNumericGcdRangeIntoBitSet(true, 2, 1, 1_700_000_000_000L);
+ }
+
+ /** Tests rangeIntoBitSet on GCD-encoded sparse sorted numeric doc values. */
+ public void testSortedNumericGcdEncodedSparseRangeIntoBitSet() throws
Exception {
+ doTestSortedNumericGcdRangeIntoBitSet(false, 4, 100, 500_000L);
+ }
+
+ /** Tests rangeIntoBitSet with negative values to exercise saturating shift
overflow paths. */
+ public void testSortedNumericGcdNegativeValuesRangeIntoBitSet() throws
Exception {
+ doTestSortedNumericGcdRangeIntoBitSet(true, 3, 7, -1_000_000_000L);
+ }
+
+ private void doTestSortedNumericGcdRangeIntoBitSet(
+ boolean dense, int cardinality, long gcd, long offset) throws Exception {
+ int numDocs = 4096 * 2;
+ try (Directory dir = newDirectory()) {
+ IndexWriterConfig iwc = new IndexWriterConfig().setCodec(new
Lucene104Codec());
+ try (IndexWriter w = new IndexWriter(dir, iwc)) {
+ for (int docID = 0; docID < numDocs; docID++) {
+ Document doc = new Document();
+ if (dense || docID % 3 != 0) {
+ long base = ((docID * 13L) % 100) * gcd + offset;
+ for (int i = 0; i < cardinality; i++) {
+ doc.add(SortedNumericDocValuesField.indexedField("sn", base + i
* gcd));
+ }
+ }
+ w.addDocument(doc);
+ }
+ w.forceMerge(1);
+ }
+
+ try (DirectoryReader reader = DirectoryReader.open(dir)) {
+ LeafReaderContext ctx = reader.leaves().get(0);
+ long queryMin = 20 * gcd + offset;
Review Comment:
Looks like queryMin and queryMax are always `N * gcd + offset`, valid bounds
that lead to must-hit some docIds. I see `transformGcdBounds` could returns
null indicating that the queryMin and queryMax lands between two gcd multiples,
this is a useful early-exit shortcut. Worth a test case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]