Pulkitg64 commented on code in PR #16383:
URL: https://github.com/apache/lucene/pull/16383#discussion_r3572176206


##########
lucene/core/src/test/org/apache/lucene/search/TestVectorScorer.java:
##########
@@ -77,6 +83,12 @@ private Directory getIndexStore(String field, VectorEncoding 
encoding, float[]..
           v[j] = (byte) contents[i][j];
         }
         doc.add(new KnnByteVectorField(field, v, EUCLIDEAN));
+      } else if (encoding == VectorEncoding.FLOAT16) {
+        short[] v = new short[contents[i].length];
+        for (int j = 0; j < v.length; j++) {
+          v[j] = Float.floatToFloat16(contents[i][j]);
+        }
+        doc.add(new KnnFloat16VectorField(field, v, EUCLIDEAN));

Review Comment:
   Actually the float case is also using `EUCLIDEAN`. 
   
   ```
     public KnnFloatVectorField(String name, float[] vector) {
       this(name, vector, VectorSimilarityFunction.EUCLIDEAN);
     }
   ```
   
   Let me check what happens if I use random Encoding.



##########
lucene/test-framework/src/java/org/apache/lucene/tests/index/BaseKnnVectorsFormatTestCase.java:
##########


Review Comment:
   For all the backward codec, it doesn't because we have overridden this 
function with something like this:
   ```
   @Override
   protected VectorEncoding randomVectorEncoding() {
       return random().nextBoolean() ? VectorEncoding.BYTE : 
VectorEncoding.FLOAT32;
   }
   
   ```
   
   For for latest codecs we are producing Float16 encoding sometimes:
   
   ```
   protected VectorEncoding randomVectorEncoding() {
       return 
VectorEncoding.values()[random().nextInt(VectorEncoding.values().length)];
   }
   ```



-- 
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