Skip to content

Commit 22f740d

Browse files
committed
Use a system property to turn off direct IO if needed
1 parent 9c86a05 commit 22f740d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
@SuppressForbidden(reason = "Copied from lucene")
5555
public class ES818FlatVectorsReader extends FlatVectorsReader {
5656

57+
private static final boolean USE_DIRECT_IO = Boolean.parseBoolean(System.getProperty("vector.rescoring.directio", "true"));
58+
5759
private static final long SHALLOW_SIZE = RamUsageEstimator.shallowSizeOfInstance(ES818FlatVectorsReader.class);
5860

5961
private final IntObjectHashMap<FieldEntry> fields = new IntObjectHashMap<>();
@@ -120,9 +122,11 @@ private static IndexInput openDataInput(
120122
) throws IOException {
121123
String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, fileExtension);
122124
// use direct IO for accessing raw vector data for searches
123-
IndexInput in = context.context() == IOContext.Context.DEFAULT && state.directory instanceof DirectIOIndexInputSupplier did
124-
? did.openInputDirect(fileName, context)
125-
: state.directory.openInput(fileName, context);
125+
IndexInput in = USE_DIRECT_IO
126+
&& context.context() == IOContext.Context.DEFAULT
127+
&& state.directory instanceof DirectIOIndexInputSupplier did
128+
? did.openInputDirect(fileName, context)
129+
: state.directory.openInput(fileName, context);
126130
boolean success = false;
127131
try {
128132
int versionVectorData = CodecUtil.checkIndexHeader(

0 commit comments

Comments
 (0)