rmuir commented on code in PR #899:
URL: https://github.com/apache/lucene/pull/899#discussion_r877101477
##########
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:
I'm not really seeing the path to vectorization here though. At least not
based on what i see here. Like i said, I really do think it should block the
issue because if we add support to the index format it is difficult/impossible
to get rid of.
--
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]