4646
4747import java .io .IOException ;
4848import java .io .UncheckedIOException ;
49+ import java .util .Map ;
4950
5051import static org .apache .lucene .codecs .lucene99 .Lucene99HnswVectorsReader .readSimilarityFunction ;
5152import 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