thecoop commented on code in PR #14510:
URL: https://github.com/apache/lucene/pull/14510#discussion_r2071743905
##########
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:
Currently, `ReadAdvice.NORMAL` doesn't have a corresponding
`DataAccessHint`, so you get that by not specifying the `DataAccessHint` but
then as the default is now `ReadAdvice.RANDOM`, you need some way to explicitly
specify 'I want the OS default behaviour here'.
Maybe we do have a `DataAccessHint.DEFAULT`, but then doesn't
`DataAccessHint` just mirror `ReadAdvice`?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]