Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ public Query rewrite(IndexSearcher indexSearcher) throws IOException {
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;
}
Expand Down
19 changes: 9 additions & 10 deletions lucene/core/src/java/org/apache/lucene/index/DocValuesSkipper.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.io.IOException;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.IndexSearcher;

/**
* Skipper for {@link DocValues}.
Expand Down Expand Up @@ -128,12 +127,12 @@ public final void advance(long minValue, long maxValue) throws IOException {
* 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 stated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param reader the index reader to be stated
* @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
}
Expand All @@ -152,12 +151,12 @@ public static long globalMinValue(IndexSearcher searcher, String field) throws I
* 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 stated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param reader the index reader to be stated
* @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
}
Expand All @@ -175,12 +174,12 @@ public static long globalMaxValue(IndexSearcher searcher, String field) throws I
/**
* 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 stated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param reader the index reader to be stated
* @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();
Expand Down