thecoop commented on code in PR #14510: URL: https://github.com/apache/lucene/pull/14510#discussion_r2075540345
########## lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java: ########## @@ -277,6 +277,32 @@ public final long getMaxChunkSize() { return 1L << chunkSizePower; } + public static ReadAdvice toReadAdvice(IOContext context) { + if (context.context() == IOContext.Context.MERGE + || context.context() == IOContext.Context.FLUSH) { + return ReadAdvice.SEQUENTIAL; + } + + if (context.hints().contains(DataAccessHint.RANDOM)) { + return ReadAdvice.RANDOM; + } + if (context.hints().contains(DataAccessHint.SEQUENTIAL)) { + return ReadAdvice.SEQUENTIAL; + } + + if (context.hints().contains(FileTypeHint.DATA) + || context.hints().contains(FileTypeHint.INDEX)) { + return ReadAdvice.NORMAL; + } + // Postings have a forward-only access pattern, so pass ReadAdvice.NORMAL to perform + // readahead. + if (context.hints().contains(FileDataHint.POSTINGS)) { + return ReadAdvice.NORMAL; + } Review Comment: I've taken another look at this, and reduced MMapDirectory down to only check `DataAccessHint` and `FileTypeHint`, without changing behavior. -- 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. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org