mirror of https://github.com/apache/lucene.git
Fix build error
This commit is contained in:
parent
b97aadb925
commit
972dbfb174
|
@ -450,7 +450,7 @@ public final class Lucene95HnswVectorsWriter extends KnnVectorsWriter {
|
||||||
new OffHeapByteVectorValues.DenseOffHeapVectorValues(
|
new OffHeapByteVectorValues.DenseOffHeapVectorValues(
|
||||||
fieldInfo.getVectorDimension(),
|
fieldInfo.getVectorDimension(),
|
||||||
docsWithField.cardinality(),
|
docsWithField.cardinality(),
|
||||||
vectorDataInput,
|
vectorDataInput.toRandomAccessInput(),
|
||||||
byteSize,
|
byteSize,
|
||||||
defaultFlatVectorScorer,
|
defaultFlatVectorScorer,
|
||||||
fieldInfo.getVectorSimilarityFunction()));
|
fieldInfo.getVectorSimilarityFunction()));
|
||||||
|
@ -462,7 +462,7 @@ public final class Lucene95HnswVectorsWriter extends KnnVectorsWriter {
|
||||||
new OffHeapFloatVectorValues.DenseOffHeapVectorValues(
|
new OffHeapFloatVectorValues.DenseOffHeapVectorValues(
|
||||||
fieldInfo.getVectorDimension(),
|
fieldInfo.getVectorDimension(),
|
||||||
docsWithField.cardinality(),
|
docsWithField.cardinality(),
|
||||||
vectorDataInput,
|
vectorDataInput.toRandomAccessInput(),
|
||||||
byteSize,
|
byteSize,
|
||||||
defaultFlatVectorScorer,
|
defaultFlatVectorScorer,
|
||||||
fieldInfo.getVectorSimilarityFunction()));
|
fieldInfo.getVectorSimilarityFunction()));
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class VectorScorerBenchmark {
|
||||||
static KnnVectorValues vectorValues(
|
static KnnVectorValues vectorValues(
|
||||||
int dims, int size, IndexInput in, VectorSimilarityFunction sim) throws IOException {
|
int dims, int size, IndexInput in, VectorSimilarityFunction sim) throws IOException {
|
||||||
return new OffHeapByteVectorValues.DenseOffHeapVectorValues(
|
return new OffHeapByteVectorValues.DenseOffHeapVectorValues(
|
||||||
dims, size, in.slice("test", 0, in.length()), dims, new ThrowingFlatVectorScorer(), sim);
|
dims, size, in.toRandomAccessInput(), dims, new ThrowingFlatVectorScorer(), sim);
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class ThrowingFlatVectorScorer implements FlatVectorsScorer {
|
static final class ThrowingFlatVectorScorer implements FlatVectorsScorer {
|
||||||
|
|
|
@ -303,7 +303,7 @@ public final class Lucene99FlatVectorsWriter extends FlatVectorsWriter {
|
||||||
new OffHeapByteVectorValues.DenseOffHeapVectorValues(
|
new OffHeapByteVectorValues.DenseOffHeapVectorValues(
|
||||||
fieldInfo.getVectorDimension(),
|
fieldInfo.getVectorDimension(),
|
||||||
docsWithField.cardinality(),
|
docsWithField.cardinality(),
|
||||||
finalVectorDataInput,
|
finalVectorDataInput.toRandomAccessInput(),
|
||||||
fieldInfo.getVectorDimension() * Byte.BYTES,
|
fieldInfo.getVectorDimension() * Byte.BYTES,
|
||||||
vectorsScorer,
|
vectorsScorer,
|
||||||
fieldInfo.getVectorSimilarityFunction()));
|
fieldInfo.getVectorSimilarityFunction()));
|
||||||
|
@ -313,7 +313,7 @@ public final class Lucene99FlatVectorsWriter extends FlatVectorsWriter {
|
||||||
new OffHeapFloatVectorValues.DenseOffHeapVectorValues(
|
new OffHeapFloatVectorValues.DenseOffHeapVectorValues(
|
||||||
fieldInfo.getVectorDimension(),
|
fieldInfo.getVectorDimension(),
|
||||||
docsWithField.cardinality(),
|
docsWithField.cardinality(),
|
||||||
finalVectorDataInput,
|
finalVectorDataInput.toRandomAccessInput(),
|
||||||
fieldInfo.getVectorDimension() * Float.BYTES,
|
fieldInfo.getVectorDimension() * Float.BYTES,
|
||||||
vectorsScorer,
|
vectorsScorer,
|
||||||
fieldInfo.getVectorSimilarityFunction()));
|
fieldInfo.getVectorSimilarityFunction()));
|
||||||
|
|
|
@ -524,7 +524,7 @@ public final class Lucene99ScalarQuantizedVectorsWriter extends FlatVectorsWrite
|
||||||
compress,
|
compress,
|
||||||
fieldInfo.getVectorSimilarityFunction(),
|
fieldInfo.getVectorSimilarityFunction(),
|
||||||
vectorsScorer,
|
vectorsScorer,
|
||||||
quantizationDataInput)));
|
quantizationDataInput.toRandomAccessInput())));
|
||||||
} finally {
|
} finally {
|
||||||
if (success == false) {
|
if (success == false) {
|
||||||
IOUtils.closeWhileHandlingException(tempQuantizedVectorData, quantizationDataInput);
|
IOUtils.closeWhileHandlingException(tempQuantizedVectorData, quantizationDataInput);
|
||||||
|
|
|
@ -152,6 +152,14 @@ public abstract class IndexInput extends DataInput implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Convert this IndexInput a RandomAccessInput. */
|
||||||
|
public RandomAccessInput toRandomAccessInput() throws IOException {
|
||||||
|
if (this instanceof RandomAccessInput) {
|
||||||
|
return (RandomAccessInput) this;
|
||||||
|
}
|
||||||
|
return randomAccessSlice(0, length());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a random-access slice of this index input, with the given offset and length.
|
* Creates a random-access slice of this index input, with the given offset and length.
|
||||||
*
|
*
|
||||||
|
@ -214,6 +222,15 @@ public abstract class IndexInput extends DataInput implements Closeable {
|
||||||
slice.prefetch(offset, length);
|
slice.prefetch(offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object clone() {
|
||||||
|
try {
|
||||||
|
return super.clone();
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
throw new Error("This cannot happen: Failing to clone RandomAccessInput", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RandomAccessInput(" + IndexInput.this.toString() + ")";
|
return "RandomAccessInput(" + IndexInput.this.toString() + ")";
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.lucene.index.VectorSimilarityFunction;
|
||||||
import org.apache.lucene.store.FilterIndexInput;
|
import org.apache.lucene.store.FilterIndexInput;
|
||||||
import org.apache.lucene.store.IndexInput;
|
import org.apache.lucene.store.IndexInput;
|
||||||
import org.apache.lucene.store.MemorySegmentAccessInput;
|
import org.apache.lucene.store.MemorySegmentAccessInput;
|
||||||
|
import org.apache.lucene.store.RandomAccessInput;
|
||||||
import org.apache.lucene.util.hnsw.RandomVectorScorer;
|
import org.apache.lucene.util.hnsw.RandomVectorScorer;
|
||||||
|
|
||||||
abstract sealed class Lucene99MemorySegmentByteVectorScorer
|
abstract sealed class Lucene99MemorySegmentByteVectorScorer
|
||||||
|
@ -40,8 +41,14 @@ abstract sealed class Lucene99MemorySegmentByteVectorScorer
|
||||||
* returned.
|
* returned.
|
||||||
*/
|
*/
|
||||||
public static Optional<Lucene99MemorySegmentByteVectorScorer> create(
|
public static Optional<Lucene99MemorySegmentByteVectorScorer> create(
|
||||||
VectorSimilarityFunction type, IndexInput input, KnnVectorValues values, byte[] queryVector) {
|
VectorSimilarityFunction type,
|
||||||
|
RandomAccessInput slice,
|
||||||
|
KnnVectorValues values,
|
||||||
|
byte[] queryVector) {
|
||||||
assert values instanceof ByteVectorValues;
|
assert values instanceof ByteVectorValues;
|
||||||
|
if (!(slice instanceof IndexInput input)) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
input = FilterIndexInput.unwrapOnlyTest(input);
|
input = FilterIndexInput.unwrapOnlyTest(input);
|
||||||
if (!(input instanceof MemorySegmentAccessInput msInput)) {
|
if (!(input instanceof MemorySegmentAccessInput msInput)) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.lucene.index.VectorSimilarityFunction;
|
||||||
import org.apache.lucene.store.FilterIndexInput;
|
import org.apache.lucene.store.FilterIndexInput;
|
||||||
import org.apache.lucene.store.IndexInput;
|
import org.apache.lucene.store.IndexInput;
|
||||||
import org.apache.lucene.store.MemorySegmentAccessInput;
|
import org.apache.lucene.store.MemorySegmentAccessInput;
|
||||||
|
import org.apache.lucene.store.RandomAccessInput;
|
||||||
import org.apache.lucene.util.hnsw.RandomVectorScorer;
|
import org.apache.lucene.util.hnsw.RandomVectorScorer;
|
||||||
import org.apache.lucene.util.hnsw.RandomVectorScorerSupplier;
|
import org.apache.lucene.util.hnsw.RandomVectorScorerSupplier;
|
||||||
|
|
||||||
|
@ -42,8 +43,11 @@ public abstract sealed class Lucene99MemorySegmentByteVectorScorerSupplier
|
||||||
* optional is returned.
|
* optional is returned.
|
||||||
*/
|
*/
|
||||||
static Optional<RandomVectorScorerSupplier> create(
|
static Optional<RandomVectorScorerSupplier> create(
|
||||||
VectorSimilarityFunction type, IndexInput input, KnnVectorValues values) {
|
VectorSimilarityFunction type, RandomAccessInput slice, KnnVectorValues values) {
|
||||||
assert values instanceof ByteVectorValues;
|
assert values instanceof ByteVectorValues;
|
||||||
|
if (!(slice instanceof IndexInput input)) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
input = FilterIndexInput.unwrapOnlyTest(input);
|
input = FilterIndexInput.unwrapOnlyTest(input);
|
||||||
if (!(input instanceof MemorySegmentAccessInput msInput)) {
|
if (!(input instanceof MemorySegmentAccessInput msInput)) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
|
@ -232,6 +232,12 @@ abstract class MemorySegmentIndexInput extends IndexInput
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFloats(long pos, float[] dst, int offset, int len) throws IOException {
|
||||||
|
seek(pos);
|
||||||
|
readFloats(dst, offset, len);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFloats(float[] dst, int offset, int length) throws IOException {
|
public void readFloats(float[] dst, int offset, int length) throws IOException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -178,18 +178,13 @@ public class TestFlatVectorScorer extends LuceneTestCase {
|
||||||
ByteVectorValues byteVectorValues(int dims, int size, IndexInput in, VectorSimilarityFunction sim)
|
ByteVectorValues byteVectorValues(int dims, int size, IndexInput in, VectorSimilarityFunction sim)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return new OffHeapByteVectorValues.DenseOffHeapVectorValues(
|
return new OffHeapByteVectorValues.DenseOffHeapVectorValues(
|
||||||
dims, size, in.slice("byteValues", 0, in.length()), dims, flatVectorsScorer, sim);
|
dims, size, in.toRandomAccessInput(), dims, flatVectorsScorer, sim);
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatVectorValues floatVectorValues(
|
FloatVectorValues floatVectorValues(
|
||||||
int dims, int size, IndexInput in, VectorSimilarityFunction sim) throws IOException {
|
int dims, int size, IndexInput in, VectorSimilarityFunction sim) throws IOException {
|
||||||
return new OffHeapFloatVectorValues.DenseOffHeapVectorValues(
|
return new OffHeapFloatVectorValues.DenseOffHeapVectorValues(
|
||||||
dims,
|
dims, size, in.toRandomAccessInput(), dims * Float.BYTES, flatVectorsScorer, sim);
|
||||||
size,
|
|
||||||
in.slice("floatValues", 0, in.length()),
|
|
||||||
dims * Float.BYTES,
|
|
||||||
flatVectorsScorer,
|
|
||||||
sim);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Concatenates float arrays as byte[]. */
|
/** Concatenates float arrays as byte[]. */
|
||||||
|
|
|
@ -381,13 +381,13 @@ public class TestVectorScorer extends LuceneTestCase {
|
||||||
KnnVectorValues vectorValues(int dims, int size, IndexInput in, VectorSimilarityFunction sim)
|
KnnVectorValues vectorValues(int dims, int size, IndexInput in, VectorSimilarityFunction sim)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return new OffHeapByteVectorValues.DenseOffHeapVectorValues(
|
return new OffHeapByteVectorValues.DenseOffHeapVectorValues(
|
||||||
dims, size, in.slice("byteValues", 0, in.length()), dims, MEMSEG_SCORER, sim);
|
dims, size, in.toRandomAccessInput(), dims, MEMSEG_SCORER, sim);
|
||||||
}
|
}
|
||||||
|
|
||||||
KnnVectorValues floatVectorValues(int dims, int size, IndexInput in, VectorSimilarityFunction sim)
|
KnnVectorValues floatVectorValues(int dims, int size, IndexInput in, VectorSimilarityFunction sim)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return new OffHeapFloatVectorValues.DenseOffHeapVectorValues(
|
return new OffHeapFloatVectorValues.DenseOffHeapVectorValues(
|
||||||
dims, size, in.slice("floatValues", 0, in.length()), dims, MEMSEG_SCORER, sim);
|
dims, size, in.toRandomAccessInput(), dims, MEMSEG_SCORER, sim);
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates the vector based on the given ordinal, which is reproducible given the ord and dims
|
// creates the vector based on the given ordinal, which is reproducible given the ord and dims
|
||||||
|
|
Loading…
Reference in New Issue