mikemccand commented on a change in pull request #697: LUCENE-8833: Allow 
MMapDirectory subclasses to pre-load per IndexInput
URL: https://github.com/apache/lucene-solr/pull/697#discussion_r299496125
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java
 ##########
 @@ -231,20 +231,24 @@ public final int getMaxChunkSize() {
   /** Creates an IndexInput for the file with the given name. */
   @Override
   public IndexInput openInput(String name, IOContext context) throws 
IOException {
+    return openInput(name, context, this.preload);
+  }
+
+  protected IndexInput openInput(String name, IOContext context, boolean 
preload) throws IOException {
     ensureOpen();
     ensureCanRead(name);
     Path path = directory.resolve(name);
     try (FileChannel c = FileChannel.open(path, StandardOpenOption.READ)) {
       final String resourceDescription = "MMapIndexInput(path=\"" + 
path.toString() + "\")";
       final boolean useUnmap = getUseUnmap();
       return ByteBufferIndexInput.newInstance(resourceDescription,
-          map(resourceDescription, c, 0, c.size()), 
+          map(resourceDescription, c, 0, c.size(), preload),
           c.size(), chunkSizePower, new ByteBufferGuard(resourceDescription, 
useUnmap ? CLEANER : null));
     }
   }
 
   /** Maps a file into a set of buffers */
-  final ByteBuffer[] map(String resourceDescription, FileChannel fc, long 
offset, long length) throws IOException {
+  final ByteBuffer[] map(String resourceDescription, FileChannel fc, long 
offset, long length, boolean preload) throws IOException {
 
 Review comment:
   It's somewhat confusing that the `preload` parameter shadows the instance 
variable; maybe rename the instance variable to `globalPreload` or 
`preloadDefault` or so to prevent future confusion?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to