Skip to content
Merged
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
7 changes: 5 additions & 2 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ API Changes
* GITHUB#16052: Remove IOException from LeafReader#getPointValues, LeafReader#terms,
LeafReader#getDocCount signatures. (Ignacio Vera)

* GITHUB#16388: Remove IOException from LeafReader#getDocValuesSkipper signature.
(Alan Woodward)

* GITHUB#16387: Don't throw IOException from PointValues metadata methods. (Alan Woodward)

* GITHUB#16281: The checkIntegrity() method of codec Producer APIs gains a OneMerge parameter,
which is used to check for aborted merges during checksum validation. (Tanguy Leroux)

Expand Down Expand Up @@ -313,8 +318,6 @@ API Changes

* GITHUB#16363: Add API to use a custom `DictionarySuggester` instead of hardcoded `GeneratingSuggester`

* GITHUB#16387: Don't throw IOException from PointValues metadata methods. (Alan Woodward)

New Features
---------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected DocValuesProducer() {}
* thread-safe: it will only be used by a single thread. The return value is undefined if {@link
* FieldInfo#docValuesSkipIndexType()} returns {@link DocValuesSkipIndexType#NONE}.
*/
public abstract DocValuesSkipper getSkipper(FieldInfo field) throws IOException;
public abstract DocValuesSkipper getSkipper(FieldInfo field);

/**
* Checks consistency of this producer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2516,13 +2516,16 @@ long getLongValue(long index) throws IOException {
}

@Override
public DocValuesSkipper getSkipper(FieldInfo field) throws IOException {
public DocValuesSkipper getSkipper(FieldInfo field) {
final DocValuesSkipperEntry entry = skippers.get(field.number);

final IndexInput skipperSource = skipIndexData != null ? skipIndexData : data;
final IndexInput input = skipperSource.slice("doc value skipper", entry.offset, entry.length);

// TODO: should we write to disk the actual max level for this segment?
return new DocValuesSkipper() {

IndexInput input;

final int[] minDocID = new int[SKIP_INDEX_MAX_LEVEL];
final int[] maxDocID = new int[SKIP_INDEX_MAX_LEVEL];

Expand All @@ -2539,6 +2542,9 @@ public DocValuesSkipper getSkipper(FieldInfo field) throws IOException {

@Override
public void advance(int target) throws IOException {
if (input == null) {
input = skipperSource.slice("doc value skipper", entry.offset, entry.length);
}
if (target > entry.maxDocId) {
// skipper is exhausted
for (int i = 0; i < SKIP_INDEX_MAX_LEVEL; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
}

@Override
public DocValuesSkipper getSkipper(FieldInfo field) throws IOException {
public DocValuesSkipper getSkipper(FieldInfo field) {
DocValuesProducer producer = fields.get(field.number);
return producer == null ? null : producer.getSkipper(field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public final SortedSetDocValues getSortedSetDocValues(String field) throws IOExc
}

@Override
public final DocValuesSkipper getDocValuesSkipper(String field) throws IOException {
public final DocValuesSkipper getDocValuesSkipper(String field) {
ensureOpen();
FieldInfo fi = getFieldInfos().fieldInfo(field);
if (fi == null || fi.docValuesSkipIndexType() == DocValuesSkipIndexType.NONE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public final CacheHelper getReaderCacheHelper() {
}

@Override
public DocValuesSkipper getDocValuesSkipper(String field) throws IOException {
public DocValuesSkipper getDocValuesSkipper(String field) {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public final void advance(long minValue, long maxValue) throws IOException {
* @param reader the index reader to be queried
* @param field the field to retrieve values for
*/
public static long globalMinValue(IndexReader reader, String field) throws IOException {
public static long globalMinValue(IndexReader reader, String field) {
long minValue = Long.MAX_VALUE;
for (LeafReaderContext ctx : reader.leaves()) {
if (ctx.reader().getFieldInfos().fieldInfo(field) == null) {
Expand All @@ -166,7 +166,7 @@ public static long globalMinValue(IndexReader reader, String field) throws IOExc
* @param reader the index reader to be queried
* @param field the field to retrieve values for
*/
public static long globalMaxValue(IndexReader reader, String field) throws IOException {
public static long globalMaxValue(IndexReader reader, String field) {
long maxValue = Long.MIN_VALUE;
for (LeafReaderContext ctx : reader.leaves()) {
if (ctx.reader().getFieldInfos().fieldInfo(field) == null) {
Expand All @@ -189,7 +189,7 @@ public static long globalMaxValue(IndexReader reader, String field) throws IOExc
* @param reader the index reader to be queried
* @param field the field to retrieve values for
*/
public static int globalDocCount(IndexReader reader, String field) throws IOException {
public static int globalDocCount(IndexReader reader, String field) {
int docCount = 0;
for (LeafReaderContext ctx : reader.leaves()) {
DocValuesSkipper skipper = ctx.reader().getDocValuesSkipper(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public SortedSetDocValues getSortedSetDocValues(String field) throws IOException
}

@Override
public DocValuesSkipper getDocValuesSkipper(String field) throws IOException {
public DocValuesSkipper getDocValuesSkipper(String field) {
ensureOpen();
return in.getDocValuesSkipper(field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public final PostingsEnum postings(Term term) throws IOException {
* interest, or {@code null} if a skip index was not indexed. The returned instance should be
* confined to the thread that created it.
*/
public abstract DocValuesSkipper getDocValuesSkipper(String field) throws IOException;
public abstract DocValuesSkipper getDocValuesSkipper(String field);

/**
* Returns {@link FloatVectorValues} for this field, or null if no {@link FloatVectorValues} were
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public SortedSetDocValues getSortedSetDocValues(String field) throws IOException
}

@Override
public DocValuesSkipper getDocValuesSkipper(String field) throws IOException {
public DocValuesSkipper getDocValuesSkipper(String field) {
ensureOpen();
LeafReader reader = fieldToReader.get(field);
return reader == null ? null : reader.getDocValuesSkipper(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
}

@Override
public DocValuesSkipper getSkipper(FieldInfo field) throws IOException {
public DocValuesSkipper getSkipper(FieldInfo field) {
DocValuesProducer dvProducer = dvProducersByField.get(field.number);
assert dvProducer != null;
return dvProducer.getSkipper(field);
Expand Down
48 changes: 20 additions & 28 deletions lucene/core/src/java/org/apache/lucene/index/SegmentOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,39 +142,31 @@ private long getSortValue(LeafReader reader) {
}

private long loadSortValue(LeafReader reader) {
try {
DocValuesSkipper skipper = reader.getDocValuesSkipper(field);
if (skipper != null) {
if (skipper.docCount() == reader.maxDoc() || missingValue == null) {
return reverse ? skipper.maxValue() : skipper.minValue();
}
if (reverse) {
return Math.max(skipper.maxValue(), missingValue);
} else {
return Math.min(skipper.minValue(), missingValue);
}
DocValuesSkipper skipper = reader.getDocValuesSkipper(field);
if (skipper != null) {
if (skipper.docCount() == reader.maxDoc() || missingValue == null) {
return reverse ? skipper.maxValue() : skipper.minValue();
}
PointValues pointValues = reader.getPointValues(field);
if (pointValues != null) {
if (pointValues.getDocCount() == reader.maxDoc() || missingValue == null) {
if (reverse) {
return pointDecoder.applyAsLong(pointValues.getMaxPackedValue());
} else {
return pointDecoder.applyAsLong(pointValues.getMinPackedValue());
}
}
if (reverse) {
return Math.max(skipper.maxValue(), missingValue);
} else {
return Math.min(skipper.minValue(), missingValue);
}
}
PointValues pointValues = reader.getPointValues(field);
if (pointValues != null) {
if (pointValues.getDocCount() == reader.maxDoc() || missingValue == null) {
if (reverse) {
return Math.max(
pointDecoder.applyAsLong(pointValues.getMaxPackedValue()), missingValue);
return pointDecoder.applyAsLong(pointValues.getMaxPackedValue());
} else {
return Math.min(
pointDecoder.applyAsLong(pointValues.getMinPackedValue()), missingValue);
return pointDecoder.applyAsLong(pointValues.getMinPackedValue());
}
}
} catch (IOException _) {
// We can't rethrow exceptions from inside a Comparator, so we instead
// return as if there are no index structures to read values from.
return reverse ? Long.MAX_VALUE : Long.MIN_VALUE;
if (reverse) {
return Math.max(pointDecoder.applyAsLong(pointValues.getMaxPackedValue()), missingValue);
} else {
return Math.min(pointDecoder.applyAsLong(pointValues.getMinPackedValue()), missingValue);
}
}
return reverse ? Long.MAX_VALUE : Long.MIN_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
}

@Override
public DocValuesSkipper getSkipper(FieldInfo field) throws IOException {
public DocValuesSkipper getSkipper(FieldInfo field) {
return reader.getDocValuesSkipper(field.name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
}

@Override
public DocValuesSkipper getSkipper(FieldInfo field) throws IOException {
public DocValuesSkipper getSkipper(FieldInfo field) {
throw new UnsupportedOperationException("This method is for searching not for merging");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ public void close() throws IOException {
}

@Override
public DocValuesSkipper getSkipper(FieldInfo field) throws IOException {
public DocValuesSkipper getSkipper(FieldInfo field) {
// We can hardly return information about min/max values if doc IDs have been reordered.
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.lucene.search;

import java.io.IOException;
import org.apache.lucene.index.DocValuesSkipper;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReader;
Expand Down Expand Up @@ -51,17 +50,16 @@ public record Stats(long min, long max, int docCount) {}
* @param field the name of the numeric field
* @return a {@link Stats} containing the global min, max, and doc count, or {@code null} if
* neither {@link PointValues} nor {@link DocValuesSkipper} are available for the field
* @throws IOException if an I/O error occurs
*/
public static Stats getStats(IndexReader reader, String field) throws IOException {
public static Stats getStats(IndexReader reader, String field) {
final Stats result = getStatsFromPoints(reader, field);
if (result != null) {
return result;
}
return getStatsFromSkipper(reader, field);
}

private static Stats getStatsFromPoints(IndexReader reader, String field) throws IOException {
private static Stats getStatsFromPoints(IndexReader reader, String field) {
final byte[] minPacked = PointValues.getMinPackedValue(reader, field);
final byte[] maxPacked = PointValues.getMaxPackedValue(reader, field);
if (minPacked == null
Expand All @@ -74,7 +72,7 @@ private static Stats getStatsFromPoints(IndexReader reader, String field) throws
return new Stats(decodeLong(minPacked), decodeLong(maxPacked), docCount);
}

private static Stats getStatsFromSkipper(IndexReader reader, String field) throws IOException {
private static Stats getStatsFromSkipper(IndexReader reader, String field) {
Long min = null;
Long max = null;
int docCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public SortedSetDocValues getSortedSetDocValues(String field) throws IOException
}

@Override
public DocValuesSkipper getDocValuesSkipper(String field) throws IOException {
public DocValuesSkipper getDocValuesSkipper(String field) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ public SortedSetDocValues getSortedSetDocValues(String field) {
}

@Override
public DocValuesSkipper getDocValuesSkipper(String field) throws IOException {
public DocValuesSkipper getDocValuesSkipper(String field) {
// Skipping isn't needed on a 1-doc index.
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
}

@Override
public DocValuesSkipper getSkipper(FieldInfo field) throws IOException {
public DocValuesSkipper getSkipper(FieldInfo field) {
assert fieldInfos.fieldInfo(field.name).number == field.number;
assert field.docValuesSkipIndexType() != DocValuesSkipIndexType.NONE;
DocValuesSkipper skipper = in.getSkipper(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ public SortedSetDocValues getSortedSetDocValues(String field) throws IOException
}

@Override
public DocValuesSkipper getDocValuesSkipper(String field) throws IOException {
public DocValuesSkipper getDocValuesSkipper(String field) {
DocValuesSkipper skipper = super.getDocValuesSkipper(field);
FieldInfo fi = getFieldInfos().fieldInfo(field);
if (skipper != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public NumericDocValues getNormValues(String field) throws IOException {
}

@Override
public DocValuesSkipper getDocValuesSkipper(String field) throws IOException {
public DocValuesSkipper getDocValuesSkipper(String field) {
ensureOpen();
FieldInfo fi = getFieldInfos().fieldInfo(field);
if (fi == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
}

@Override
public DocValuesSkipper getSkipper(FieldInfo field) throws IOException {
public DocValuesSkipper getSkipper(FieldInfo field) {
return in.getSkipper(remapFieldInfo(field));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public NumericDocValues getNormValues(String field) throws IOException {
}

@Override
public DocValuesSkipper getDocValuesSkipper(String field) throws IOException {
public DocValuesSkipper getDocValuesSkipper(String field) {
return null;
}

Expand Down
Loading