Pulkitg64 commented on code in PR #14792: URL: https://github.com/apache/lucene/pull/14792#discussion_r2168100860
########## lucene/core/src/java/org/apache/lucene/codecs/lucene99/OffHeapQuantizedFloatVectorValues.java: ########## @@ -0,0 +1,365 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.lucene.codecs.lucene99; + +import java.io.IOException; +import java.nio.ByteBuffer; +import org.apache.lucene.codecs.hnsw.FlatVectorsScorer; +import org.apache.lucene.codecs.lucene90.IndexedDISI; +import org.apache.lucene.codecs.lucene95.HasIndexSlice; +import org.apache.lucene.codecs.lucene95.OrdToDocDISIReaderConfiguration; +import org.apache.lucene.index.FloatVectorValues; +import org.apache.lucene.index.VectorSimilarityFunction; +import org.apache.lucene.search.DocIdSetIterator; +import org.apache.lucene.search.VectorScorer; +import org.apache.lucene.store.IndexInput; +import org.apache.lucene.util.Bits; +import org.apache.lucene.util.hnsw.RandomVectorScorer; +import org.apache.lucene.util.packed.DirectMonotonicReader; +import org.apache.lucene.util.quantization.ScalarQuantizer; + +/** Read the vector values from the index input. This supports both iterated and random access. */ +public abstract class OffHeapQuantizedFloatVectorValues extends FloatVectorValues + implements HasIndexSlice { + + protected final int dimension; + protected final int size; + protected final int numBytes; + protected final ScalarQuantizer scalarQuantizer; + protected final VectorSimilarityFunction similarityFunction; + protected final FlatVectorsScorer vectorsScorer; + protected final boolean compress; + + protected final IndexInput slice; + protected final float[] floatValue; + protected final byte[] binaryValue; + protected final ByteBuffer byteBuffer; + protected final int byteSize; + protected int curOrd = -1; + protected final float[] scoreCorrectionConstant = new float[1]; + + OffHeapQuantizedFloatVectorValues( + int dimension, + int size, + ScalarQuantizer scalarQuantizer, + VectorSimilarityFunction similarityFunction, + FlatVectorsScorer vectorsScorer, + boolean compress, + IndexInput slice) { + this.dimension = dimension; + this.size = size; + this.slice = slice; + this.scalarQuantizer = scalarQuantizer; + this.compress = compress; + if (scalarQuantizer.getBits() <= 4 && compress) { + this.numBytes = (dimension + 1) >> 1; + } else { + this.numBytes = dimension; + } + this.byteSize = this.numBytes + Float.BYTES; + byteBuffer = ByteBuffer.allocate(dimension); + binaryValue = byteBuffer.array(); + floatValue = new float[dimension]; + this.similarityFunction = similarityFunction; + this.vectorsScorer = vectorsScorer; + } + + public ScalarQuantizer getScalarQuantizer() { + return scalarQuantizer; + } Review Comment: Removed from new revision. -- 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