You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by pa...@apache.org on 2025/12/26 05:19:02 UTC
(lucene) branch branch_10x updated: Refactor DocValuesSkipper stat methods to accept IndexReader instead of IndexSearcher (#15514)
This is an automated email from the ASF dual-hosted git repository.
panguixin pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_10x by this push:
new eaa9e037d05 Refactor DocValuesSkipper stat methods to accept IndexReader instead of IndexSearcher (#15514)
eaa9e037d05 is described below
commit eaa9e037d0548dcfeabdd4b33b10eed78a55cae3
Author: panguixin <pa...@bytedance.com>
AuthorDate: Fri Dec 26 13:09:41 2025 +0800
Refactor DocValuesSkipper stat methods to accept IndexReader instead of IndexSearcher (#15514)
---
lucene/CHANGES.txt | 2 ++
.../document/SortedNumericDocValuesRangeQuery.java | 6 +++---
.../org/apache/lucene/index/DocValuesSkipper.java | 19 +++++++++----------
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 0d2da656582..81505b10756 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -35,6 +35,8 @@ API Changes
* GITHUB#15501: Introduce optional access to backing vector values from the scorer (Chris Hegarty)
+* GITHUB#15514: Refactor DocValuesSkipper stat methods to accept IndexReader instead of IndexSearcher (Pan Guixin)
+
New Features
---------------------
* GITHUB#15328: VectorSimilarityFunction.getValues() now implements doubleVal allowing its
diff --git a/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesRangeQuery.java b/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesRangeQuery.java
index 67dc7d4b3e8..94f248b903e 100644
--- a/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesRangeQuery.java
@@ -93,14 +93,14 @@ final class SortedNumericDocValuesRangeQuery extends NumericDocValuesRangeQuery
if (lowerValue > upperValue) {
return MatchNoDocsQuery.INSTANCE;
}
- long globalMin = DocValuesSkipper.globalMinValue(indexSearcher, field);
- long globalMax = DocValuesSkipper.globalMaxValue(indexSearcher, field);
+ long globalMin = DocValuesSkipper.globalMinValue(indexSearcher.getIndexReader(), field);
+ long globalMax = DocValuesSkipper.globalMaxValue(indexSearcher.getIndexReader(), field);
if (lowerValue > globalMax || upperValue < globalMin) {
return MatchNoDocsQuery.INSTANCE;
}
if (lowerValue <= globalMin
&& upperValue >= globalMax
- && DocValuesSkipper.globalDocCount(indexSearcher, field)
+ && DocValuesSkipper.globalDocCount(indexSearcher.getIndexReader(), field)
== indexSearcher.getIndexReader().maxDoc()) {
return MatchAllDocsQuery.INSTANCE;
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocValuesSkipper.java b/lucene/core/src/java/org/apache/lucene/index/DocValuesSkipper.java
index 93fd72faba1..79364b00173 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocValuesSkipper.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocValuesSkipper.java
@@ -18,7 +18,6 @@ package org.apache.lucene.index;
import java.io.IOException;
import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.IndexSearcher;
/**
* Skipper for {@link DocValues}.
@@ -128,12 +127,12 @@ public abstract class DocValuesSkipper {
* Returns the minimum value for a field across all segments, or {@link Long#MIN_VALUE} if not
* available
*
- * @param searcher a searcher over the index
+ * @param reader the index reader to be queried
* @param field the field to retrieve values for
*/
- public static long globalMinValue(IndexSearcher searcher, String field) throws IOException {
+ public static long globalMinValue(IndexReader reader, String field) throws IOException {
long minValue = Long.MAX_VALUE;
- for (LeafReaderContext ctx : searcher.getLeafContexts()) {
+ for (LeafReaderContext ctx : reader.leaves()) {
if (ctx.reader().getFieldInfos().fieldInfo(field) == null) {
continue; // no field values in this segment, so we can ignore it
}
@@ -152,12 +151,12 @@ public abstract class DocValuesSkipper {
* Returns the maximum value for a field across all segments, or {@link Long#MIN_VALUE} if not
* available
*
- * @param searcher a searcher over the index
+ * @param reader the index reader to be queried
* @param field the field to retrieve values for
*/
- public static long globalMaxValue(IndexSearcher searcher, String field) throws IOException {
+ public static long globalMaxValue(IndexReader reader, String field) throws IOException {
long maxValue = Long.MIN_VALUE;
- for (LeafReaderContext ctx : searcher.getLeafContexts()) {
+ for (LeafReaderContext ctx : reader.leaves()) {
if (ctx.reader().getFieldInfos().fieldInfo(field) == null) {
continue; // no field values in this segment, so we can ignore it
}
@@ -175,12 +174,12 @@ public abstract class DocValuesSkipper {
/**
* Returns the total skipper document count for a field across all segments
*
- * @param searcher a searcher over the index
+ * @param reader the index reader to be queried
* @param field the field to retrieve values for
*/
- public static int globalDocCount(IndexSearcher searcher, String field) throws IOException {
+ public static int globalDocCount(IndexReader reader, String field) throws IOException {
int docCount = 0;
- for (LeafReaderContext ctx : searcher.getLeafContexts()) {
+ for (LeafReaderContext ctx : reader.leaves()) {
DocValuesSkipper skipper = ctx.reader().getDocValuesSkipper(field);
if (skipper != null) {
docCount += skipper.docCount();