Skip to content

Commit ae3d668

Browse files
committed
fix directio reader
1 parent 647bf75 commit ae3d668

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

server/src/main/java/org/elasticsearch/index/codec/vectors/es818/DirectIOLucene99FlatVectorsReader.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646

4747
import java.io.IOException;
4848
import java.io.UncheckedIOException;
49+
import java.util.Map;
4950

5051
import static org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsReader.readSimilarityFunction;
5152
import static org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsReader.readVectorEncoding;
@@ -169,6 +170,12 @@ public long ramBytesUsed() {
169170
return SHALLOW_SIZE + fields.ramBytesUsed();
170171
}
171172

173+
@Override
174+
public Map<String, Long> getOffHeapByteSize(FieldInfo fieldInfo) {
175+
final FieldEntry entry = getFieldEntryOrThrow(fieldInfo.name);
176+
return Map.of(DirectIOLucene99FlatVectorsFormat.VECTOR_DATA_EXTENSION, entry.vectorDataLength());
177+
}
178+
172179
@Override
173180
public void checkIntegrity() throws IOException {
174181
CodecUtil.checksumEntireFile(vectorData);
@@ -185,12 +192,17 @@ public FlatVectorsReader getMergeInstance() {
185192
}
186193
}
187194

188-
private FieldEntry getFieldEntry(String field, VectorEncoding expectedEncoding) {
195+
private FieldEntry getFieldEntryOrThrow(String field) {
189196
final FieldInfo info = fieldInfos.fieldInfo(field);
190-
final FieldEntry fieldEntry;
191-
if (info == null || (fieldEntry = fields.get(info.number)) == null) {
197+
final FieldEntry entry;
198+
if (info == null || (entry = fields.get(info.number)) == null) {
192199
throw new IllegalArgumentException("field=\"" + field + "\" not found");
193200
}
201+
return entry;
202+
}
203+
204+
private FieldEntry getFieldEntry(String field, VectorEncoding expectedEncoding) {
205+
final FieldEntry fieldEntry = getFieldEntryOrThrow(field);
194206
if (fieldEntry.vectorEncoding != expectedEncoding) {
195207
throw new IllegalArgumentException(
196208
"field=\"" + field + "\" is encoded as: " + fieldEntry.vectorEncoding + " expected: " + expectedEncoding

0 commit comments

Comments
 (0)