rmuir commented on code in PR #899: URL: https://github.com/apache/lucene/pull/899#discussion_r875320987
########## lucene/core/src/java/org/apache/lucene/codecs/lucene92/ExpandingRandomAccessVectorValues.java: ########## @@ -0,0 +1,57 @@ +package org.apache.lucene.codecs.lucene92; + +import org.apache.lucene.index.RandomAccessVectorValues; +import org.apache.lucene.index.RandomAccessVectorValuesProducer; +import org.apache.lucene.util.BytesRef; + +import java.io.IOException; + +public class ExpandingRandomAccessVectorValues implements RandomAccessVectorValuesProducer { + + private final RandomAccessVectorValuesProducer delegate; + private final float scale; + + /** + * Wraps an existing vector values producer. Floating point vector values will be produced by scaling + * byte-quantized values read from the values produced by the input. + */ + protected ExpandingRandomAccessVectorValues(RandomAccessVectorValuesProducer in, float scale) { + this.delegate = in; + assert scale != 0; + this.scale = scale; + } + + @Override + public RandomAccessVectorValues randomAccess() throws IOException { + RandomAccessVectorValues delegateValues = delegate.randomAccess(); + float[] value = new float[delegateValues.dimension()];; + + return new RandomAccessVectorValues() { + + @Override + public int size() { + return delegateValues.size(); + } + + @Override + public int dimension() { + return delegateValues.dimension(); + } + + @Override + public float[] vectorValue(int targetOrd) throws IOException { + BytesRef binaryValue = delegateValues.binaryValue(targetOrd); + byte[] bytes = binaryValue.bytes; + for (int i = 0, j = binaryValue.offset; i < value.length; i++, j++) { + value[i] = bytes[j] * scale; Review Comment: and i think we don't want reinterpret, but this one: https://docs.oracle.com/en/java/javase/16/docs/api/jdk.incubator.vector/jdk/incubator/vector/ByteVector.html#viewAsFloatingLanes() -- 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: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org