Skip to content

Commit

Permalink
Overrides getMergeInstance for NativeEngine99VectorReader
Browse files Browse the repository at this point in the history
Signed-off-by: Tejas Shah <[email protected]>
  • Loading branch information
shatejas committed Oct 12, 2024
1 parent b0d82b7 commit f9c2df4
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

package org.opensearch.knn.index.codec.KNN990Codec;

import lombok.extern.log4j.Log4j2;
import org.apache.lucene.codecs.KnnVectorsReader;
import org.apache.lucene.codecs.hnsw.FlatVectorsReader;
import org.apache.lucene.index.ByteVectorValues;
Expand All @@ -37,6 +38,7 @@
* Vectors reader class for reading the flat vectors for native engines. The class provides methods for iterating
* over the vectors and retrieving their values.
*/
@Log4j2
public class NativeEngines990KnnVectorsReader extends KnnVectorsReader {

private final FlatVectorsReader flatVectorsReader;
Expand All @@ -49,6 +51,12 @@ public NativeEngines990KnnVectorsReader(final SegmentReadState state, final Flat
loadCacheKeyMap();
}

private NativeEngines990KnnVectorsReader(final NativeEngines990KnnVectorsReader reader, final FlatVectorsReader flatVectorsReader) {
this.segmentReadState = reader.segmentReadState;
this.flatVectorsReader = flatVectorsReader;
quantizationStateCacheKeyPerField = reader.quantizationStateCacheKeyPerField;
}

/**
* Checks consistency of this reader.
*
Expand Down Expand Up @@ -161,6 +169,12 @@ public void search(String field, byte[] target, KnnCollector knnCollector, Bits
throw new UnsupportedOperationException("Search functionality using codec is not supported with Native Engine Reader");
}

@Override
public KnnVectorsReader getMergeInstance() {
log.info("Getting merge instance for NativeEngines990KnnVectorsReader");
return new NativeEngines990KnnVectorsReader(this, flatVectorsReader.getMergeInstance());
}

/**
* Closes this stream and releases any system resources associated
* with it. If the stream is already closed then invoking this
Expand Down

0 comments on commit f9c2df4

Please sign in to comment.