romseygeek commented on code in PR #16050:
URL: https://github.com/apache/lucene/pull/16050#discussion_r3232648524


##########
lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java:
##########
@@ -91,4 +91,38 @@ public void longValues(int size, int[] docs, long[] values, 
long defaultValue)
       values[i] = value;
     }
   }
+
+  /**
+   * Fills a {@link org.apache.lucene.util.FixedBitSet} with the doc IDs in 
{@code [fromDoc, toDoc)}
+   * whose values are in {@code [minValue, maxValue]}. This is a bulk 
operation that avoids per-doc
+   * virtual dispatch overhead.
+   *
+   * <p>The default implementation falls back to per-doc evaluation via {@link 
#advanceExact} and
+   * {@link #longValue}. Subclasses with random-access storage (e.g., dense 
fixed-bitsPerValue
+   * fields) can override this for significantly better performance.
+   *
+   * @param fromDoc first doc ID to evaluate (inclusive)
+   * @param toDoc last doc ID to evaluate (exclusive)
+   * @param minValue lower bound of the range (inclusive)
+   * @param maxValue upper bound of the range (inclusive)
+   * @param bitSet the bitset to fill
+   * @param offset subtracted from each doc ID before setting the bit
+   */
+  public void rangeIntoBitSet(
+      int fromDoc,
+      int toDoc,
+      long minValue,
+      long maxValue,
+      org.apache.lucene.util.FixedBitSet bitSet,

Review Comment:
   Does this need to be explicitly a FixedBitSet or can we use BitSet in the 
signature instead?



##########
lucene/core/src/java/org/apache/lucene/search/BatchDocValuesRangeIterator.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.search;
+
+import java.io.IOException;
+import org.apache.lucene.index.DocValuesSkipper;
+import org.apache.lucene.index.NumericDocValues;
+import org.apache.lucene.util.FixedBitSet;
+
+/**
+ * A {@link DocIdSetIterator} for numeric doc values range queries that 
batch-evaluates values for
+ * MAYBE blocks. Instead of checking one doc at a time through a {@link
+ * org.apache.lucene.search.TwoPhaseIterator}, this iterator reads values in a 
tight loop and sets
+ * bits directly in a {@link FixedBitSet}, enabling the {@link 
DenseConjunctionBulkScorer} to use
+ * the faster bitset intersection path.
+ *
+ * <p>This is used for dense single-valued numeric fields with a skip index.
+ */
+public final class BatchDocValuesRangeIterator extends DocIdSetIterator {
+
+  private final SkipBlockRangeIterator blockIterator;
+  private final NumericDocValues values;
+  private final long minValue;
+  private final long maxValue;
+  private int doc = -1;
+
+  public BatchDocValuesRangeIterator(
+      NumericDocValues values, DocValuesSkipper skipper, long minValue, long 
maxValue) {
+    this.blockIterator = new SkipBlockRangeIterator(skipper, minValue, 
maxValue);
+    this.values = values;
+    this.minValue = minValue;
+    this.maxValue = maxValue;
+  }
+
+  @Override
+  public int docID() {
+    return doc;
+  }
+
+  @Override
+  public int nextDoc() throws IOException {
+    return advance(doc + 1);
+  }
+
+  @Override
+  public int advance(int target) throws IOException {
+    // Use the block iterator to skip NO blocks
+    int blockDoc = blockIterator.docID();
+    if (blockDoc < target) {
+      blockDoc = blockIterator.advance(target);
+    }
+    if (blockDoc == NO_MORE_DOCS) {
+      return doc = NO_MORE_DOCS;
+    }
+
+    // For YES blocks, all docs match — find the first doc with a value
+    if (blockIterator.getMatch() == SkipBlockRangeIterator.Match.YES) {
+      return doc = blockDoc;
+    }
+
+    // For MAYBE blocks, scan forward to find a matching doc
+    int docToCheck = Math.max(target, blockDoc);
+    // Use the actual block boundary (not docIDRunEnd which returns doc+1 for 
MAYBE blocks)
+    int currentBlockEnd = blockIterator.blockEnd();
+    while (docToCheck != NO_MORE_DOCS) {
+      if (values.advanceExact(docToCheck)) {
+        long v = values.longValue();
+        if (v >= minValue && v <= maxValue) {
+          return doc = docToCheck;
+        }
+      }
+      docToCheck++;
+      // Check if we've left the current block
+      if (docToCheck >= currentBlockEnd) {
+        // Move to next matching block
+        blockDoc = blockIterator.advance(docToCheck);
+        if (blockDoc == NO_MORE_DOCS) {
+          return doc = NO_MORE_DOCS;
+        }
+        docToCheck = blockDoc;
+        if (blockIterator.getMatch() == SkipBlockRangeIterator.Match.YES) {

Review Comment:
   Also assert here



##########
lucene/core/src/java/org/apache/lucene/search/BatchDocValuesRangeIterator.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.search;
+
+import java.io.IOException;
+import org.apache.lucene.index.DocValuesSkipper;
+import org.apache.lucene.index.NumericDocValues;
+import org.apache.lucene.util.FixedBitSet;
+
+/**
+ * A {@link DocIdSetIterator} for numeric doc values range queries that 
batch-evaluates values for
+ * MAYBE blocks. Instead of checking one doc at a time through a {@link
+ * org.apache.lucene.search.TwoPhaseIterator}, this iterator reads values in a 
tight loop and sets
+ * bits directly in a {@link FixedBitSet}, enabling the {@link 
DenseConjunctionBulkScorer} to use
+ * the faster bitset intersection path.
+ *
+ * <p>This is used for dense single-valued numeric fields with a skip index.
+ */
+public final class BatchDocValuesRangeIterator extends DocIdSetIterator {
+
+  private final SkipBlockRangeIterator blockIterator;
+  private final NumericDocValues values;
+  private final long minValue;
+  private final long maxValue;
+  private int doc = -1;
+
+  public BatchDocValuesRangeIterator(
+      NumericDocValues values, DocValuesSkipper skipper, long minValue, long 
maxValue) {
+    this.blockIterator = new SkipBlockRangeIterator(skipper, minValue, 
maxValue);
+    this.values = values;
+    this.minValue = minValue;
+    this.maxValue = maxValue;
+  }
+
+  @Override
+  public int docID() {
+    return doc;
+  }
+
+  @Override
+  public int nextDoc() throws IOException {
+    return advance(doc + 1);
+  }
+
+  @Override
+  public int advance(int target) throws IOException {
+    // Use the block iterator to skip NO blocks
+    int blockDoc = blockIterator.docID();
+    if (blockDoc < target) {
+      blockDoc = blockIterator.advance(target);
+    }
+    if (blockDoc == NO_MORE_DOCS) {
+      return doc = NO_MORE_DOCS;
+    }
+
+    // For YES blocks, all docs match — find the first doc with a value
+    if (blockIterator.getMatch() == SkipBlockRangeIterator.Match.YES) {
+      return doc = blockDoc;
+    }
+

Review Comment:
   Let's assert that we're not in a YES_IF_PRESENT block



##########
lucene/core/src/test/org/apache/lucene/search/TestSkipBlockRangeIteratorIntoBitSet.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.search;
+
+import java.util.Random;
+import org.apache.lucene.codecs.lucene104.Lucene104Codec;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.NumericDocValuesField;
+import org.apache.lucene.document.SortedNumericDocValuesField;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MMapDirectory;
+import org.apache.lucene.tests.util.LuceneTestCase;
+
+/**
+ * Verifies correctness of single-field and multi-field doc values range 
queries using {@link
+ * BatchDocValuesRangeIterator}.
+ *
+ * <p>Key behavioral notes:
+ *
+ * <ul>
+ *   <li>Single-field range with a second clause (e.g., MatchAllDocsQuery): 
goes through {@code
+ *       DenseConjunctionBulkScorer}, which calls {@code 
BatchDocValuesRangeIterator.intoBitSet()},
+ *       dispatching to SIMD via {@code NumericDocValues.rangeIntoBitSet()} 
for MAYBE blocks.
+ *   <li>Multi-field range: {@code DenseConjunctionBulkScorer} intersects all 
clauses via {@code
+ *       intoBitSet()}, with YES blocks set directly and MAYBE blocks 
evaluated via {@code
+ *       rangeIntoBitSet()}.
+ * </ul>
+ */
+public class TestSkipBlockRangeIteratorIntoBitSet extends LuceneTestCase {
+
+  private static final int DOC_COUNT = 50_000;

Review Comment:
   This seems like a lot of docs?



##########
lucene/core/src/java/org/apache/lucene/search/BatchDocValuesRangeIterator.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.search;
+
+import java.io.IOException;
+import org.apache.lucene.index.DocValuesSkipper;
+import org.apache.lucene.index.NumericDocValues;
+import org.apache.lucene.util.FixedBitSet;
+
+/**
+ * A {@link DocIdSetIterator} for numeric doc values range queries that 
batch-evaluates values for
+ * MAYBE blocks. Instead of checking one doc at a time through a {@link
+ * org.apache.lucene.search.TwoPhaseIterator}, this iterator reads values in a 
tight loop and sets
+ * bits directly in a {@link FixedBitSet}, enabling the {@link 
DenseConjunctionBulkScorer} to use
+ * the faster bitset intersection path.
+ *
+ * <p>This is used for dense single-valued numeric fields with a skip index.
+ */
+public final class BatchDocValuesRangeIterator extends DocIdSetIterator {
+
+  private final SkipBlockRangeIterator blockIterator;
+  private final NumericDocValues values;
+  private final long minValue;
+  private final long maxValue;
+  private int doc = -1;
+
+  public BatchDocValuesRangeIterator(
+      NumericDocValues values, DocValuesSkipper skipper, long minValue, long 
maxValue) {
+    this.blockIterator = new SkipBlockRangeIterator(skipper, minValue, 
maxValue);
+    this.values = values;
+    this.minValue = minValue;
+    this.maxValue = maxValue;
+  }
+
+  @Override
+  public int docID() {
+    return doc;
+  }
+
+  @Override
+  public int nextDoc() throws IOException {
+    return advance(doc + 1);
+  }
+
+  @Override
+  public int advance(int target) throws IOException {
+    // Use the block iterator to skip NO blocks
+    int blockDoc = blockIterator.docID();
+    if (blockDoc < target) {
+      blockDoc = blockIterator.advance(target);
+    }
+    if (blockDoc == NO_MORE_DOCS) {
+      return doc = NO_MORE_DOCS;
+    }
+
+    // For YES blocks, all docs match — find the first doc with a value
+    if (blockIterator.getMatch() == SkipBlockRangeIterator.Match.YES) {
+      return doc = blockDoc;
+    }
+
+    // For MAYBE blocks, scan forward to find a matching doc
+    int docToCheck = Math.max(target, blockDoc);
+    // Use the actual block boundary (not docIDRunEnd which returns doc+1 for 
MAYBE blocks)
+    int currentBlockEnd = blockIterator.blockEnd();
+    while (docToCheck != NO_MORE_DOCS) {
+      if (values.advanceExact(docToCheck)) {
+        long v = values.longValue();
+        if (v >= minValue && v <= maxValue) {
+          return doc = docToCheck;
+        }
+      }
+      docToCheck++;
+      // Check if we've left the current block
+      if (docToCheck >= currentBlockEnd) {
+        // Move to next matching block
+        blockDoc = blockIterator.advance(docToCheck);
+        if (blockDoc == NO_MORE_DOCS) {
+          return doc = NO_MORE_DOCS;
+        }
+        docToCheck = blockDoc;
+        if (blockIterator.getMatch() == SkipBlockRangeIterator.Match.YES) {
+          return doc = docToCheck;
+        }
+        currentBlockEnd = blockIterator.blockEnd();
+      }
+    }
+    return doc = NO_MORE_DOCS;
+  }
+
+  @Override
+  public long cost() {
+    return values.cost();
+  }
+
+  @Override
+  public int docIDRunEnd() throws IOException {
+    return blockIterator.docIDRunEnd();
+  }
+
+  @Override
+  public void intoBitSet(int upTo, FixedBitSet bitSet, int offset) throws 
IOException {
+    while (doc < upTo) {
+      // Advance block iterator if needed
+      if (blockIterator.docID() < doc) {
+        blockIterator.advance(doc);
+      }
+      if (blockIterator.docID() >= upTo || blockIterator.docID() == 
NO_MORE_DOCS) {
+        doc = blockIterator.docID() == NO_MORE_DOCS ? NO_MORE_DOCS : 
blockIterator.docID();
+        return;
+      }
+
+      int blockStart = Math.max(doc, blockIterator.docID());
+      SkipBlockRangeIterator.Match match = blockIterator.getMatch();
+
+      // For YES/YES_IF_PRESENT: docIDRunEnd() respects multi-level block 
promotion.
+      // For MAYBE: docIDRunEnd() returns doc+1 (conservative), but we need 
the actual
+      // block boundary to bulk-evaluate the whole block with 
rangeIntoBitSet().
+      int blockEnd =
+          match == SkipBlockRangeIterator.Match.MAYBE
+              ? Math.min(upTo, blockIterator.blockEnd())
+              : Math.min(upTo, blockIterator.docIDRunEnd());
+
+      switch (match) {
+        case YES:
+          // All docs in this range match — set all bits
+          bitSet.set(blockStart - offset, blockEnd - offset);
+          break;
+
+        case YES_IF_PRESENT:

Review Comment:
   We're not expecting YES_IF_PRESENT here are we?  If so then we need to take 
it into account in advance(), if not we should just assert false here.



##########
lucene/core/src/test/org/apache/lucene/search/TestSkipBlockRangeIteratorIntoBitSet.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.search;
+
+import java.util.Random;
+import org.apache.lucene.codecs.lucene104.Lucene104Codec;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.NumericDocValuesField;
+import org.apache.lucene.document.SortedNumericDocValuesField;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MMapDirectory;
+import org.apache.lucene.tests.util.LuceneTestCase;
+
+/**
+ * Verifies correctness of single-field and multi-field doc values range 
queries using {@link
+ * BatchDocValuesRangeIterator}.
+ *
+ * <p>Key behavioral notes:
+ *
+ * <ul>
+ *   <li>Single-field range with a second clause (e.g., MatchAllDocsQuery): 
goes through {@code
+ *       DenseConjunctionBulkScorer}, which calls {@code 
BatchDocValuesRangeIterator.intoBitSet()},
+ *       dispatching to SIMD via {@code NumericDocValues.rangeIntoBitSet()} 
for MAYBE blocks.
+ *   <li>Multi-field range: {@code DenseConjunctionBulkScorer} intersects all 
clauses via {@code
+ *       intoBitSet()}, with YES blocks set directly and MAYBE blocks 
evaluated via {@code
+ *       rangeIntoBitSet()}.
+ * </ul>
+ */
+public class TestSkipBlockRangeIteratorIntoBitSet extends LuceneTestCase {
+
+  private static final int DOC_COUNT = 50_000;
+
+  private Directory dir;
+  private DirectoryReader reader;
+  private IndexSearcher searcher;
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    dir = MMapDirectory.open(createTempDir("intoBitSetTest"));
+    IndexWriterConfig iwc = new IndexWriterConfig();
+    iwc.setCodec(new Lucene104Codec());
+    IndexWriter w = new IndexWriter(dir, iwc);
+    Random r = new Random(42);

Review Comment:
   This should use `random()` to get the test seed



##########
lucene/core/src/test/org/apache/lucene/search/TestSkipBlockRangeIteratorIntoBitSet.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.search;
+
+import java.util.Random;
+import org.apache.lucene.codecs.lucene104.Lucene104Codec;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.NumericDocValuesField;
+import org.apache.lucene.document.SortedNumericDocValuesField;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MMapDirectory;
+import org.apache.lucene.tests.util.LuceneTestCase;
+
+/**
+ * Verifies correctness of single-field and multi-field doc values range 
queries using {@link
+ * BatchDocValuesRangeIterator}.
+ *
+ * <p>Key behavioral notes:
+ *
+ * <ul>
+ *   <li>Single-field range with a second clause (e.g., MatchAllDocsQuery): 
goes through {@code
+ *       DenseConjunctionBulkScorer}, which calls {@code 
BatchDocValuesRangeIterator.intoBitSet()},
+ *       dispatching to SIMD via {@code NumericDocValues.rangeIntoBitSet()} 
for MAYBE blocks.
+ *   <li>Multi-field range: {@code DenseConjunctionBulkScorer} intersects all 
clauses via {@code
+ *       intoBitSet()}, with YES blocks set directly and MAYBE blocks 
evaluated via {@code
+ *       rangeIntoBitSet()}.
+ * </ul>
+ */
+public class TestSkipBlockRangeIteratorIntoBitSet extends LuceneTestCase {

Review Comment:
   I think we should be doing some lower-level testing here, specifically of 
the intoBitSet call - you can look at TestSkipBlockRangeIterator to get an idea 
of what to check.



##########
lucene/core/src/test/org/apache/lucene/search/TestSkipBlockRangeIteratorIntoBitSet.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.search;
+
+import java.util.Random;
+import org.apache.lucene.codecs.lucene104.Lucene104Codec;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.NumericDocValuesField;
+import org.apache.lucene.document.SortedNumericDocValuesField;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MMapDirectory;
+import org.apache.lucene.tests.util.LuceneTestCase;
+
+/**
+ * Verifies correctness of single-field and multi-field doc values range 
queries using {@link
+ * BatchDocValuesRangeIterator}.
+ *
+ * <p>Key behavioral notes:
+ *
+ * <ul>
+ *   <li>Single-field range with a second clause (e.g., MatchAllDocsQuery): 
goes through {@code
+ *       DenseConjunctionBulkScorer}, which calls {@code 
BatchDocValuesRangeIterator.intoBitSet()},
+ *       dispatching to SIMD via {@code NumericDocValues.rangeIntoBitSet()} 
for MAYBE blocks.
+ *   <li>Multi-field range: {@code DenseConjunctionBulkScorer} intersects all 
clauses via {@code
+ *       intoBitSet()}, with YES blocks set directly and MAYBE blocks 
evaluated via {@code
+ *       rangeIntoBitSet()}.
+ * </ul>
+ */
+public class TestSkipBlockRangeIteratorIntoBitSet extends LuceneTestCase {
+
+  private static final int DOC_COUNT = 50_000;
+
+  private Directory dir;
+  private DirectoryReader reader;
+  private IndexSearcher searcher;
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    dir = MMapDirectory.open(createTempDir("intoBitSetTest"));
+    IndexWriterConfig iwc = new IndexWriterConfig();
+    iwc.setCodec(new Lucene104Codec());
+    IndexWriter w = new IndexWriter(dir, iwc);
+    Random r = new Random(42);
+    for (int i = 0; i < DOC_COUNT; i++) {
+      Document doc = new Document();
+      doc.add(NumericDocValuesField.indexedField("age", r.nextInt(100)));
+      doc.add(NumericDocValuesField.indexedField("score", r.nextInt(1000)));
+      w.addDocument(doc);
+    }
+    w.forceMerge(1);
+    reader = DirectoryReader.open(w);
+    w.close();
+    searcher = new IndexSearcher(reader);
+  }
+
+  @Override
+  public void tearDown() throws Exception {
+    reader.close();
+    dir.close();
+    super.tearDown();
+  }
+
+  /** Single-field range query returns correct results. */
+  public void testSingleFieldRangeCorrectness() throws Exception {
+    Query q = SortedNumericDocValuesField.newSlowRangeQuery("age", 20, 40);
+    int count = searcher.count(q);
+    assertTrue("Should find some docs in range [20,40]", count > 0);

Review Comment:
   I don't think we can assert this with the randomly generated values?  We 
could conceivably get all docs with value 1 on some (admittedly unlikely) seed.



##########
lucene/core/src/test/org/apache/lucene/search/TestSkipBlockRangeIteratorIntoBitSet.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.search;
+
+import java.util.Random;
+import org.apache.lucene.codecs.lucene104.Lucene104Codec;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.NumericDocValuesField;
+import org.apache.lucene.document.SortedNumericDocValuesField;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MMapDirectory;
+import org.apache.lucene.tests.util.LuceneTestCase;
+
+/**
+ * Verifies correctness of single-field and multi-field doc values range 
queries using {@link
+ * BatchDocValuesRangeIterator}.
+ *
+ * <p>Key behavioral notes:
+ *
+ * <ul>
+ *   <li>Single-field range with a second clause (e.g., MatchAllDocsQuery): 
goes through {@code

Review Comment:
   I don't think we're testing for this case?  In addition, it needs to be a 
restrictive filter of some kind, as MatchAllDocsQuery will get rewritten away 
by BQ.



-- 
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]

Reply via email to