Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import static java.lang.String.format;
import static org.elasticsearch.index.codec.vectors.IVFVectorsFormat.MAX_VECTORS_PER_CLUSTER;
import static org.elasticsearch.index.codec.vectors.IVFVectorsFormat.MIN_VECTORS_PER_CLUSTER;
import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.oneOf;

Expand Down Expand Up @@ -83,6 +85,25 @@ protected Codec getCodec() {
return TestUtil.alwaysKnnVectorsFormat(format);
}

@Override
protected void assertOffHeapByteSize(LeafReader r, String fieldName) throws IOException {
var fieldInfo = r.getFieldInfos().fieldInfo(fieldName);

if (r instanceof CodecReader codecReader) {
KnnVectorsReader knnVectorsReader = codecReader.getVectorReader();
if (knnVectorsReader instanceof PerFieldKnnVectorsFormat.FieldsReader fieldsReader) {
knnVectorsReader = fieldsReader.getFieldReader(fieldName);
}
var offHeap = knnVectorsReader.getOffHeapByteSize(fieldInfo);
long totalByteSize = offHeap.values().stream().mapToLong(Long::longValue).sum();
// IVF doesn't report stats at the moment
assertThat(offHeap, anEmptyMap());
assertThat(totalByteSize, equalTo(0L));
} else {
throw new AssertionError("unexpected:" + r.getClass());
}
}

@Override
public void testAdvance() throws Exception {
// TODO re-enable with hierarchical IVF, clustering as it is is flaky
Expand Down