Skip to content

Commit 849ce20

Browse files
authored
Bring new quantized format inline with old quantized format (#15622)
* Bring new quantized format inline with old quantized format * iter
1 parent dd32676 commit 849ce20

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104ScalarQuantizedVectorScorer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
import org.apache.lucene.util.hnsw.UpdateableRandomVectorScorer;
3232
import org.apache.lucene.util.quantization.OptimizedScalarQuantizer;
3333

34-
/** Vector scorer over OptimizedScalarQuantized vectors */
34+
/**
35+
* Vector scorer over OptimizedScalarQuantized vectors
36+
*
37+
* @lucene.experimental
38+
*/
3539
public class Lucene104ScalarQuantizedVectorScorer implements FlatVectorsScorer {
3640
private final FlatVectorsScorer nonQuantizedDelegate;
3741

@@ -103,7 +107,7 @@ public RandomVectorScorer getRandomVectorScorer(
103107
return nonQuantizedDelegate.getRandomVectorScorer(similarityFunction, vectorValues, target);
104108
}
105109

106-
RandomVectorScorerSupplier getRandomVectorScorerSupplier(
110+
public RandomVectorScorerSupplier getRandomVectorScorerSupplier(
107111
VectorSimilarityFunction similarityFunction,
108112
QuantizedByteVectorValues scoringVectors,
109113
QuantizedByteVectorValues targetVectors) {

lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104ScalarQuantizedVectorsFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public static ScalarEncoding fromNumBits(int bits) {
199199
this.queryBitsPerDim = queryBitsPerDim;
200200
}
201201

202-
boolean isAsymmetric() {
202+
public boolean isAsymmetric() {
203203
return bits != queryBits;
204204
}
205205

lucene/core/src/java/org/apache/lucene/codecs/lucene104/OffHeapScalarQuantizedVectorValues.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ public byte[] vectorValue(int targetOrd) throws IOException {
133133
return vectorValue;
134134
}
135135

136+
@Override
137+
public IndexInput getSlice() {
138+
return slice;
139+
}
140+
136141
@Override
137142
public float getCentroidDP() {
138143
return centroidDp;
@@ -169,7 +174,7 @@ public float[] getCentroid() {
169174

170175
@Override
171176
public int getVectorByteLength() {
172-
return dimension;
177+
return vectorValue.length;
173178
}
174179

175180
static void packNibbles(byte[] unpacked, byte[] packed) {

lucene/core/src/java/org/apache/lucene/codecs/lucene104/QuantizedByteVectorValues.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818

1919
import java.io.IOException;
2020
import org.apache.lucene.codecs.lucene104.Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding;
21+
import org.apache.lucene.codecs.lucene95.HasIndexSlice;
2122
import org.apache.lucene.index.ByteVectorValues;
2223
import org.apache.lucene.search.VectorScorer;
24+
import org.apache.lucene.store.IndexInput;
2325
import org.apache.lucene.util.quantization.OptimizedScalarQuantizer;
2426

2527
/** Scalar quantized byte vector values */
26-
abstract class QuantizedByteVectorValues extends ByteVectorValues {
28+
public abstract class QuantizedByteVectorValues extends ByteVectorValues implements HasIndexSlice {
2729

2830
/**
2931
* Retrieve the corrective terms for the given vector ordinal. For the dot-product family of
@@ -82,4 +84,9 @@ public abstract OptimizedScalarQuantizer.QuantizationResult getCorrectiveTerms(i
8284

8385
@Override
8486
public abstract QuantizedByteVectorValues copy() throws IOException;
87+
88+
@Override
89+
public IndexInput getSlice() {
90+
return null;
91+
}
8592
}

0 commit comments

Comments
 (0)