msokolov commented on code in PR #899: URL: https://github.com/apache/lucene/pull/899#discussion_r877179592
########## 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: Yeah - I hear you. I will try to work out more concretely what that would look like. My initial preoccupation has been with (1) a reasonable API and (2) ensuring that 8 bits is enough to get good recall. -- 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