3333import java .nio .file .Files ;
3434import java .nio .file .Path ;
3535import java .util .HashSet ;
36+ import java .util .OptionalLong ;
3637import java .util .Set ;
3738import java .util .function .BiPredicate ;
3839
@@ -112,10 +113,17 @@ public static boolean isHybridFs(Directory directory) {
112113
113114 static final class HybridDirectory extends NIOFSDirectory implements DirectIODirectory {
114115 private final MMapDirectory delegate ;
116+ private final org .apache .lucene .misc .store .DirectIODirectory directIODelegate ;
115117
116118 HybridDirectory (LockFactory lockFactory , MMapDirectory delegate ) throws IOException {
117119 super (delegate .getDirectory (), lockFactory );
118120 this .delegate = delegate ;
121+ this .directIODelegate = new org .apache .lucene .misc .store .DirectIODirectory (delegate ) {
122+ @ Override
123+ protected boolean useDirectIO (String name , IOContext context , OptionalLong fileLength ) {
124+ return true ;
125+ }
126+ };
119127 }
120128
121129 @ Override
@@ -141,13 +149,8 @@ public IndexInput openInputDirect(String name, IOContext context) throws IOExcep
141149 // we need to do these checks on the outer directory since the inner doesn't know about pending deletes
142150 ensureOpen ();
143151 ensureCanRead (name );
144- // we switch the context here since mmap checks for the READONCE context by identity
145- context = context == Store .READONCE_CHECKSUM ? IOContext .READONCE : context ;
146- // we only use the mmap to open inputs. Everything else is managed by the NIOFSDirectory otherwise
147- // we might run into trouble with files that are pendingDelete in one directory but still
148- // listed in listAll() from the other. We on the other hand don't want to list files from both dirs
149- // and intersect for perf reasons.
150- return delegate .openInput (name , context );
152+
153+ return directIODelegate .openInput (name , context );
151154 }
152155
153156 @ Override
0 commit comments