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


##########
lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextKnnVectorsWriter.java:
##########
@@ -92,6 +93,28 @@ private void writeFloatVectorValue(FloatVectorValues 
vectors, int ord) throws IO
     newline(vectorData);
   }
 
+  @Override
+  public void writeField(FieldInfo fieldInfo, Float16VectorValues 
float16VectorValues, int maxDoc)
+      throws IOException {
+    long vectorDataOffset = vectorData.getFilePointer();
+    List<Integer> docIds = new ArrayList<>();
+    KnnVectorValues.DocIndexIterator iter = float16VectorValues.iterator();
+    for (int docV = iter.nextDoc(); docV != NO_MORE_DOCS; docV = 
iter.nextDoc()) {
+      writeFloat16VectorValue(float16VectorValues, iter.index());
+      docIds.add(docV);
+    }
+    long vectorDataLength = vectorData.getFilePointer() - vectorDataOffset;
+    writeMeta(fieldInfo, vectorDataOffset, vectorDataLength, docIds);
+  }
+
+  private void writeFloat16VectorValue(Float16VectorValues vectors, int ord) 
throws IOException {
+    // write vector value
+    short[] value = vectors.vectorValue(ord);
+    assert value.length == vectors.dimension();
+    write(vectorData, Arrays.toString(value));

Review Comment:
   Yes, that's right, these short are actually FP16 (IEEE 754) values.
   
   Since the API to input float16 vectors supports short only (both during 
indexing i.e. `KnnFloat16VectorField `and searching `KnnFloat16VectorQuery` ), 
we have kept the values here as it is without changing them to fp16 values. 
   
   But please let me know if you think we should convert these values to fp16 
first before writing them.



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