Skip to content

Commit 62283d5

Browse files
authored
Add raw OffHeapByteSize to IVFVectorsReader (#128451)
1 parent 6eb3ea6 commit 62283d5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

server/src/main/java/org/elasticsearch/index/codec/vectors/IVFVectorsReader.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.elasticsearch.search.vectors.IVFKnnSearchStrategy;
3636

3737
import java.io.IOException;
38+
import java.util.Map;
3839
import java.util.function.IntPredicate;
3940

4041
import static org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsReader.SIMILARITY_FUNCTIONS;
@@ -323,6 +324,22 @@ abstract NeighborQueue scorePostingLists(
323324
int nProbe
324325
) throws IOException;
325326

327+
@Override
328+
public Map<String, Long> getOffHeapByteSize(FieldInfo fieldInfo) {
329+
var raw = rawVectorsReader.getOffHeapByteSize(fieldInfo);
330+
FieldEntry fe = fields.get(fieldInfo.number);
331+
if (fe == null) {
332+
assert fieldInfo.getVectorEncoding() == VectorEncoding.BYTE;
333+
return raw;
334+
}
335+
return raw; // for now just return the size of raw
336+
337+
// TODO: determine desired off off-heap requirements
338+
// var centroids = Map.of(EXTENSION, fe.xxxLength());
339+
// var clusters = Map.of(EXTENSION, fe.yyyLength());
340+
// return KnnVectorsReader.mergeOffHeapByteSizeMaps(raw, centroids, clusters);
341+
}
342+
326343
@Override
327344
public void close() throws IOException {
328345
IOUtils.close(rawVectorsReader, ivfCentroids, ivfClusters);

0 commit comments

Comments
 (0)