msokolov commented on code in PR #16473:
URL: https://github.com/apache/lucene/pull/16473#discussion_r3861823299


##########
lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104ScalarQuantizedVectorScorer.java:
##########
@@ -62,38 +62,9 @@ public RandomVectorScorer getRandomVectorScorer(
       throws IOException {
     if (vectorValues instanceof QuantizedByteVectorValues qv) {
       FlatVectorsScorer.checkDimensions(target.length, qv.dimension());
-      OptimizedScalarQuantizer quantizer = qv.getQuantizer();
-      ScalarEncoding scalarEncoding = qv.getScalarEncoding();
-      byte[] scratch = new 
byte[scalarEncoding.getDiscreteDimensions(qv.dimension())];
-      final byte[] targetQuantized;
-      if (scalarEncoding.isAsymmetric() == false) {
-        targetQuantized = scratch;
-      } else {
-        // This is asymmetric quantization, we will pack the vector
-        targetQuantized = new 
byte[scalarEncoding.getQueryPackedLength(scratch.length)];
-      }
       // We make a copy as the quantization process mutates the input
-      float[] copy = ArrayUtil.copyOfSubArray(target, 0, target.length);
-      if (similarityFunction == COSINE) {
-        VectorUtil.l2normalize(copy);
-      }
-      target = copy;
-      var targetCorrectiveTerms =
-          quantizer.scalarQuantize(
-              target, scratch, scalarEncoding.getQueryBits(), 
qv.getCentroid());
-      // for asymmetric encodings with 4-bit query, we need to transpose the 
nibbles for fast
-      // scoring comparisons
-      if (scalarEncoding == ScalarEncoding.SINGLE_BIT_QUERY_NIBBLE
-          || scalarEncoding == ScalarEncoding.DIBIT_QUERY_NIBBLE) {
-        OptimizedScalarQuantizer.transposeHalfByte(scratch, targetQuantized);
-      }
-      return new RandomVectorScorer.AbstractRandomVectorScorer(qv) {
-        @Override
-        public float score(int node) throws IOException {
-          return quantizedScore(
-              targetQuantized, targetCorrectiveTerms, qv, node, 
similarityFunction);
-        }
-      };
+      return getRandomQuantizedVectorScorer(
+          similarityFunction, qv, ArrayUtil.copyOfSubArray(target, 0, 
target.length));

Review Comment:
   We have `copyArray` as sugar for this



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to