Skip to content

Commit 4b1bcdf

Browse files
authored
Expose vector values from Int7SQVectorScorerSupplier (#136416) (#136530)
Exposes the vector values from the Int7 scorer supplier, via a "capability" interface (same pattern as used elsewhere in Lucene, e.g. MemorySegmentAccess or HasIndexSlice)
1 parent ead6339 commit 4b1bcdf

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.simdvec;
11+
12+
import org.apache.lucene.util.quantization.QuantizedByteVectorValues;
13+
14+
public interface QuantizedByteVectorValuesAccess {
15+
QuantizedByteVectorValues get();
16+
}

libs/simdvec/src/main21/java/org/elasticsearch/simdvec/internal/Int7SQVectorScorerSupplier.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.apache.lucene.util.hnsw.UpdateableRandomVectorScorer;
1515
import org.apache.lucene.util.quantization.QuantizedByteVectorValues;
1616
import org.apache.lucene.util.quantization.ScalarQuantizedVectorSimilarity;
17+
import org.elasticsearch.simdvec.QuantizedByteVectorValuesAccess;
1718

1819
import java.io.IOException;
1920
import java.lang.foreign.MemorySegment;
@@ -23,7 +24,7 @@
2324
import static org.apache.lucene.index.VectorSimilarityFunction.MAXIMUM_INNER_PRODUCT;
2425
import static org.apache.lucene.util.quantization.ScalarQuantizedVectorSimilarity.fromVectorSimilarity;
2526

26-
public abstract sealed class Int7SQVectorScorerSupplier implements RandomVectorScorerSupplier {
27+
public abstract sealed class Int7SQVectorScorerSupplier implements RandomVectorScorerSupplier, QuantizedByteVectorValuesAccess {
2728

2829
static final byte BITS = 7;
2930

@@ -107,6 +108,11 @@ public void setScoringOrdinal(int node) throws IOException {
107108
};
108109
}
109110

111+
@Override
112+
public QuantizedByteVectorValues get() {
113+
return values;
114+
}
115+
110116
public static final class EuclideanSupplier extends Int7SQVectorScorerSupplier {
111117

112118
public EuclideanSupplier(MemorySegmentAccessInput input, QuantizedByteVectorValues values, float scoreCorrectionConstant) {

0 commit comments

Comments
 (0)