@@ -70,7 +70,6 @@ abstract class OffHeapScalarQuantizedFloatVectorValues extends FloatVectorValues
7070 int quantizedComponentSum ;
7171 final Lucene104ScalarQuantizedVectorsFormat .ScalarEncoding encoding ;
7272 final float [] centroid ;
73- final boolean isQuerySide ;
7473
7574 OffHeapScalarQuantizedFloatVectorValues (
7675 int dimension ,
@@ -80,20 +79,6 @@ abstract class OffHeapScalarQuantizedFloatVectorValues extends FloatVectorValues
8079 VectorSimilarityFunction similarityFunction ,
8180 FlatVectorsScorer vectorsScorer ,
8281 IndexInput slice ) {
83- this (false , dimension , size , centroid , encoding , similarityFunction , vectorsScorer , slice );
84- }
85-
86- OffHeapScalarQuantizedFloatVectorValues (
87- boolean isQuerySide ,
88- int dimension ,
89- int size ,
90- float [] centroid ,
91- Lucene104ScalarQuantizedVectorsFormat .ScalarEncoding encoding ,
92- VectorSimilarityFunction similarityFunction ,
93- FlatVectorsScorer vectorsScorer ,
94- IndexInput slice ) {
95- assert isQuerySide == false || encoding .isAsymmetric ();
96- this .isQuerySide = isQuerySide ;
9782 this .dimension = dimension ;
9883 this .size = size ;
9984 this .similarityFunction = similarityFunction ;
@@ -102,10 +87,7 @@ abstract class OffHeapScalarQuantizedFloatVectorValues extends FloatVectorValues
10287 this .centroid = centroid ;
10388 this .correctiveValues = new float [3 ];
10489 this .encoding = encoding ;
105- int docPackedLength =
106- isQuerySide
107- ? encoding .getQueryPackedLength (dimension )
108- : encoding .getDocPackedLength (dimension );
90+ int docPackedLength = encoding .getDocPackedLength (dimension );
10991 this .byteSize = docPackedLength + (Float .BYTES * 3 ) + Integer .BYTES ;
11092 this .byteBuffer = ByteBuffer .allocate (docPackedLength );
11193 this .vectorValue = new float [dimension ];
@@ -142,15 +124,26 @@ public float[] vectorValue(int targetOrd) throws IOException {
142124 case SINGLE_BIT_QUERY_NIBBLE ->
143125 OptimizedScalarQuantizer .unpackBinary (byteValue , unpackedByteVectorValue );
144126 case UNSIGNED_BYTE , SEVEN_BIT -> {
145- deQuantize (byteValue , vectorValue , encoding .getBits (), correctiveValues , centroid );
127+ deQuantize (
128+ byteValue ,
129+ vectorValue ,
130+ encoding .getBits (),
131+ correctiveValues [0 ],
132+ correctiveValues [1 ],
133+ centroid );
146134 lastOrd = targetOrd ;
147135 return vectorValue ;
148136 }
149137 }
150138
151139 // dequantize
152140 deQuantize (
153- unpackedByteVectorValue , vectorValue , encoding .getBits (), correctiveValues , centroid );
141+ unpackedByteVectorValue ,
142+ vectorValue ,
143+ encoding .getBits (),
144+ correctiveValues [0 ],
145+ correctiveValues [1 ],
146+ centroid );
154147
155148 lastOrd = targetOrd ;
156149 return vectorValue ;
@@ -219,7 +212,7 @@ static OffHeapScalarQuantizedFloatVectorValues load(
219212 }
220213
221214 /** Dense off-heap scalar quantized vector values */
222- static class DenseOffHeapVectorValues extends OffHeapScalarQuantizedFloatVectorValues {
215+ private static class DenseOffHeapVectorValues extends OffHeapScalarQuantizedFloatVectorValues {
223216 DenseOffHeapVectorValues (
224217 int dimension ,
225218 int size ,
@@ -231,38 +224,11 @@ static class DenseOffHeapVectorValues extends OffHeapScalarQuantizedFloatVectorV
231224 super (dimension , size , centroid , encoding , similarityFunction , vectorsScorer , slice );
232225 }
233226
234- DenseOffHeapVectorValues (
235- boolean isQuerySide ,
236- int dimension ,
237- int size ,
238- float [] centroid ,
239- Lucene104ScalarQuantizedVectorsFormat .ScalarEncoding encoding ,
240- VectorSimilarityFunction similarityFunction ,
241- FlatVectorsScorer vectorsScorer ,
242- IndexInput slice ) {
243- super (
244- isQuerySide ,
245- dimension ,
246- size ,
247- centroid ,
248- encoding ,
249- similarityFunction ,
250- vectorsScorer ,
251- slice );
252- }
253-
254227 @ Override
255228 public OffHeapScalarQuantizedFloatVectorValues .DenseOffHeapVectorValues copy ()
256229 throws IOException {
257230 return new OffHeapScalarQuantizedFloatVectorValues .DenseOffHeapVectorValues (
258- isQuerySide ,
259- dimension ,
260- size ,
261- centroid ,
262- encoding ,
263- similarityFunction ,
264- vectorsScorer ,
265- slice .clone ());
231+ dimension , size , centroid , encoding , similarityFunction , vectorsScorer , slice .clone ());
266232 }
267233
268234 @ Override
@@ -272,7 +238,6 @@ public Bits getAcceptOrds(Bits acceptDocs) {
272238
273239 @ Override
274240 public VectorScorer scorer (float [] target ) throws IOException {
275- assert isQuerySide == false ;
276241 OffHeapScalarQuantizedFloatVectorValues .DenseOffHeapVectorValues copy = copy ();
277242 DocIndexIterator iterator = copy .iterator ();
278243 RandomVectorScorer scorer =
@@ -316,7 +281,6 @@ private static class SparseOffHeapVectorValues extends OffHeapScalarQuantizedFlo
316281 IndexInput slice )
317282 throws IOException {
318283 super (dimension , size , centroid , encoding , similarityFunction , vectorsScorer , slice );
319- assert isQuerySide == false ;
320284 this .configuration = configuration ;
321285 this .dataIn = dataIn ;
322286 this .ordToDoc = configuration .getDirectMonotonicReader (dataIn );
@@ -326,7 +290,6 @@ private static class SparseOffHeapVectorValues extends OffHeapScalarQuantizedFlo
326290 @ Override
327291 public OffHeapScalarQuantizedFloatVectorValues .SparseOffHeapVectorValues copy ()
328292 throws IOException {
329- assert isQuerySide == false ;
330293 return new OffHeapScalarQuantizedFloatVectorValues .SparseOffHeapVectorValues (
331294 configuration ,
332295 dimension ,
@@ -369,7 +332,6 @@ public DocIndexIterator iterator() {
369332
370333 @ Override
371334 public VectorScorer scorer (float [] target ) throws IOException {
372- assert isQuerySide == false ;
373335 OffHeapScalarQuantizedFloatVectorValues .SparseOffHeapVectorValues copy = copy ();
374336 DocIndexIterator iterator = copy .iterator ();
375337 RandomVectorScorer scorer =
@@ -388,6 +350,7 @@ public DocIdSetIterator iterator() {
388350 }
389351 }
390352
353+ /** Empty vector values */
391354 private static class EmptyOffHeapVectorValues extends OffHeapScalarQuantizedFloatVectorValues {
392355 EmptyOffHeapVectorValues (
393356 int dimension ,
@@ -401,7 +364,6 @@ private static class EmptyOffHeapVectorValues extends OffHeapScalarQuantizedFloa
401364 similarityFunction ,
402365 vectorsScorer ,
403366 null );
404- assert isQuerySide == false ;
405367 }
406368
407369 @ Override
0 commit comments