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
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ 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 @@ -444,17 +444,17 @@ public byte[] getMaxPackedValue() {
}

@Override
public int getNumDimensions() throws IOException {
public int getNumDimensions() {
return config.numDims();
}

@Override
public int getNumIndexDimensions() throws IOException {
public int getNumIndexDimensions() {
return config.numIndexDims();
}

@Override
public int getBytesPerDimension() throws IOException {
public int getBytesPerDimension() {
return config.bytesPerDim();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,31 +646,31 @@ public PointTree getPointTree() throws IOException {
}

@Override
public byte[] getMinPackedValue() throws IOException {
public byte[] getMinPackedValue() {
checkAndThrow();
return in.getMinPackedValue();
}

@Override
public byte[] getMaxPackedValue() throws IOException {
public byte[] getMaxPackedValue() {
checkAndThrow();
return in.getMaxPackedValue();
}

@Override
public int getNumDimensions() throws IOException {
public int getNumDimensions() {
checkAndThrow();
return in.getNumDimensions();
}

@Override
public int getNumIndexDimensions() throws IOException {
public int getNumIndexDimensions() {
checkAndThrow();
return in.getNumIndexDimensions();
}

@Override
public int getBytesPerDimension() throws IOException {
public int getBytesPerDimension() {
checkAndThrow();
return in.getBytesPerDimension();
}
Expand Down
18 changes: 9 additions & 9 deletions lucene/core/src/java/org/apache/lucene/index/PointValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public abstract class PointValues {
*
* @see PointValues#size()
*/
public static long size(IndexReader reader, String field) throws IOException {
public static long size(IndexReader reader, String field) {
long size = 0;
for (LeafReaderContext ctx : reader.leaves()) {
PointValues values = ctx.reader().getPointValues(field);
Expand All @@ -135,7 +135,7 @@ public static long size(IndexReader reader, String field) throws IOException {
*
* @see PointValues#getDocCount()
*/
public static int getDocCount(IndexReader reader, String field) throws IOException {
public static int getDocCount(IndexReader reader, String field) {
int count = 0;
for (LeafReaderContext ctx : reader.leaves()) {
PointValues values = ctx.reader().getPointValues(field);
Expand All @@ -152,7 +152,7 @@ public static int getDocCount(IndexReader reader, String field) throws IOExcepti
*
* @see PointValues#getMinPackedValue()
*/
public static byte[] getMinPackedValue(IndexReader reader, String field) throws IOException {
public static byte[] getMinPackedValue(IndexReader reader, String field) {
byte[] minValue = null;
for (LeafReaderContext ctx : reader.leaves()) {
PointValues values = ctx.reader().getPointValues(field);
Expand Down Expand Up @@ -187,7 +187,7 @@ public static byte[] getMinPackedValue(IndexReader reader, String field) throws
*
* @see PointValues#getMaxPackedValue()
*/
public static byte[] getMaxPackedValue(IndexReader reader, String field) throws IOException {
public static byte[] getMaxPackedValue(IndexReader reader, String field) {
byte[] maxValue = null;
for (LeafReaderContext ctx : reader.leaves()) {
PointValues values = ctx.reader().getPointValues(field);
Expand Down Expand Up @@ -473,21 +473,21 @@ public final long estimateDocCount(IntersectVisitor visitor) {
/**
* Returns minimum value for each dimension, packed, or null if {@link #size} is <code>0</code>
*/
public abstract byte[] getMinPackedValue() throws IOException;
public abstract byte[] getMinPackedValue();

/**
* Returns maximum value for each dimension, packed, or null if {@link #size} is <code>0</code>
*/
public abstract byte[] getMaxPackedValue() throws IOException;
public abstract byte[] getMaxPackedValue();

/** Returns how many dimensions are represented in the values */
public abstract int getNumDimensions() throws IOException;
public abstract int getNumDimensions();

/** Returns how many dimensions are used for the index */
public abstract int getNumIndexDimensions() throws IOException;
public abstract int getNumIndexDimensions();

/** Returns the number of bytes per dimension */
public abstract int getBytesPerDimension() throws IOException;
public abstract int getBytesPerDimension();

/** Returns the total number of indexed points across all documents. */
public abstract long size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,32 +286,32 @@ public PointValues getValues(String fieldName) {
}
return new PointValues() {
@Override
public PointTree getPointTree() throws IOException {
public PointTree getPointTree() {
return values;
}

@Override
public byte[] getMinPackedValue() throws IOException {
public byte[] getMinPackedValue() {
throw new UnsupportedOperationException();
}

@Override
public byte[] getMaxPackedValue() throws IOException {
public byte[] getMaxPackedValue() {
throw new UnsupportedOperationException();
}

@Override
public int getNumDimensions() throws IOException {
public int getNumDimensions() {
throw new UnsupportedOperationException();
}

@Override
public int getNumIndexDimensions() throws IOException {
public int getNumIndexDimensions() {
throw new UnsupportedOperationException();
}

@Override
public int getBytesPerDimension() throws IOException {
public int getBytesPerDimension() {
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.apache.lucene.index;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -613,7 +612,7 @@ public PointValues getValues(String field) {
return new PointValues() {

@Override
public PointTree getPointTree() throws IOException {
public PointTree getPointTree() {
return new PointTree() {

@Override
Expand Down Expand Up @@ -681,110 +680,98 @@ public boolean moveToChild() throws IOException {

@Override
public byte[] getMinPackedValue() {
try {
byte[] minPackedValue = null;
for (PointValuesSub sub : values) {
if (minPackedValue == null) {
minPackedValue = sub.sub.getMinPackedValue().clone();
} else {
byte[] leafMinPackedValue = sub.sub.getMinPackedValue();
int numIndexDimensions = sub.sub.getNumIndexDimensions();
int numBytesPerDimension = sub.sub.getBytesPerDimension();
ArrayUtil.ByteArrayComparator comparator =
ArrayUtil.getUnsignedComparator(numBytesPerDimension);
for (int i = 0; i < numIndexDimensions; ++i) {
if (comparator.compare(
leafMinPackedValue,
i * numBytesPerDimension,
minPackedValue,
i * numBytesPerDimension)
< 0) {
System.arraycopy(
byte[] minPackedValue = null;
for (PointValuesSub sub : values) {
if (minPackedValue == null) {
minPackedValue = sub.sub.getMinPackedValue().clone();
} else {
byte[] leafMinPackedValue = sub.sub.getMinPackedValue();
int numIndexDimensions = sub.sub.getNumIndexDimensions();
int numBytesPerDimension = sub.sub.getBytesPerDimension();
ArrayUtil.ByteArrayComparator comparator =
ArrayUtil.getUnsignedComparator(numBytesPerDimension);
for (int i = 0; i < numIndexDimensions; ++i) {
if (comparator.compare(
leafMinPackedValue,
i * numBytesPerDimension,
minPackedValue,
i * numBytesPerDimension,
numBytesPerDimension);
}
i * numBytesPerDimension)
< 0) {
System.arraycopy(
leafMinPackedValue,
i * numBytesPerDimension,
minPackedValue,
i * numBytesPerDimension,
numBytesPerDimension);
}
}
}
return minPackedValue;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return minPackedValue;
}

@Override
public byte[] getMaxPackedValue() {
try {
byte[] maxPackedValue = null;
for (PointValuesSub sub : values) {
if (maxPackedValue == null) {
maxPackedValue = sub.sub.getMaxPackedValue().clone();
} else {
byte[] leafMinPackedValue = sub.sub.getMaxPackedValue();
int numIndexDimensions = sub.sub.getNumIndexDimensions();
int numBytesPerDimension = sub.sub.getBytesPerDimension();
ArrayUtil.ByteArrayComparator comparator =
ArrayUtil.getUnsignedComparator(numBytesPerDimension);
for (int i = 0; i < numIndexDimensions; ++i) {
if (comparator.compare(
leafMinPackedValue,
i * numBytesPerDimension,
maxPackedValue,
i * numBytesPerDimension)
> 0) {
System.arraycopy(
byte[] maxPackedValue = null;
for (PointValuesSub sub : values) {
if (maxPackedValue == null) {
maxPackedValue = sub.sub.getMaxPackedValue().clone();
} else {
byte[] leafMinPackedValue = sub.sub.getMaxPackedValue();
int numIndexDimensions = sub.sub.getNumIndexDimensions();
int numBytesPerDimension = sub.sub.getBytesPerDimension();
ArrayUtil.ByteArrayComparator comparator =
ArrayUtil.getUnsignedComparator(numBytesPerDimension);
for (int i = 0; i < numIndexDimensions; ++i) {
if (comparator.compare(
leafMinPackedValue,
i * numBytesPerDimension,
maxPackedValue,
i * numBytesPerDimension,
numBytesPerDimension);
}
i * numBytesPerDimension)
> 0) {
System.arraycopy(
leafMinPackedValue,
i * numBytesPerDimension,
maxPackedValue,
i * numBytesPerDimension,
numBytesPerDimension);
}
}
}
return maxPackedValue;
} catch (IOException e) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❤️

throw new UncheckedIOException(e);
}
return maxPackedValue;
}
};
}

@Override
public byte[] getMinPackedValue() throws IOException {
public byte[] getMinPackedValue() {
return getPointTree().getMinPackedValue();
}

@Override
public byte[] getMaxPackedValue() throws IOException {
public byte[] getMaxPackedValue() {
return getPointTree().getMaxPackedValue();
}

@Override
public int getNumDimensions() throws IOException {
public int getNumDimensions() {
return values.get(0).sub.getNumDimensions();
}

@Override
public int getNumIndexDimensions() throws IOException {
public int getNumIndexDimensions() {
return values.get(0).sub.getNumIndexDimensions();
}

@Override
public int getBytesPerDimension() throws IOException {
public int getBytesPerDimension() {
return values.get(0).sub.getBytesPerDimension();
}

@Override
public long size() {
try {
return getPointTree().size();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return getPointTree().size();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,27 @@ public PointTree getPointTree() throws IOException {
}

@Override
public byte[] getMinPackedValue() throws IOException {
public byte[] getMinPackedValue() {
return in.getMinPackedValue();
}

@Override
public byte[] getMaxPackedValue() throws IOException {
public byte[] getMaxPackedValue() {
return in.getMaxPackedValue();
}

@Override
public int getNumDimensions() throws IOException {
public int getNumDimensions() {
return in.getNumDimensions();
}

@Override
public int getNumIndexDimensions() throws IOException {
public int getNumIndexDimensions() {
return in.getNumIndexDimensions();
}

@Override
public int getBytesPerDimension() throws IOException {
public int getBytesPerDimension() {
return in.getBytesPerDimension();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1009,17 +1009,17 @@ public byte[] getMaxPackedValue() {
}

@Override
public int getNumDimensions() throws IOException {
public int getNumDimensions() {
return config.numDims();
}

@Override
public int getNumIndexDimensions() throws IOException {
public int getNumIndexDimensions() {
return config.numIndexDims();
}

@Override
public int getBytesPerDimension() throws IOException {
public int getBytesPerDimension() {
return config.bytesPerDim();
}

Expand Down
Loading
Loading