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


##########
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:
   These `short[]` are actually FP16 (IEEE 754) values right?  And `SimpleText` 
writes them as (opaque) shorts, including presumably negative values.



##########
lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene102/Lucene102BinaryFlatVectorsScorer.java:
##########
@@ -94,6 +94,13 @@ public RandomVectorScorer getRandomVectorScorer(
     return nonQuantizedDelegate.getRandomVectorScorer(similarityFunction, 
vectorValues, target);
   }
 
+  @Override
+  public RandomVectorScorer getRandomVectorScorer(

Review Comment:
   Is there some reason we can't add a default implementation in the base 
interface/class that does this?  It makes me nervous seeing so many 
`backwards-codecs` sources changing... but it looks like it's mostly 
(entirely?) these new `short[]` / `Float16` boilerplate methods.



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