uschindler commented on code in PR #13229: URL: https://github.com/apache/lucene/pull/13229#discussion_r1542131095
########## lucene/core/src/java/org/apache/lucene/store/IOContext.java: ########## @@ -88,4 +84,18 @@ public IOContext(MergeInfo mergeInfo) { // Merges read input segments sequentially. this(Context.MERGE, mergeInfo, null, ReadAdvice.SEQUENTIAL); } + + /** + * Return an updated {@link IOContext} that has the provided {@link ReadAdvice} if the {@link + * Context} is a {@link Context#READ} context, otherwise return this existing instance. This helps + * preserve a {@link ReadAdvice#SEQUENTIAL} advice for merging, which is always the right choice, + * while allowing {@link IndexInput}s open for searching to use arbitrary {@link ReadAdvice}s. + */ + public IOContext toReadAdvice(ReadAdvice advice) { + if (context == Context.READ) { Review Comment: How should we deal with DEFAULT. I see lots of code using DEFAULT, so I would suggest: - Remove the enum constant altogether - Do the same like for READ I think DEFAULT is mostly used for writing, but I haven't checked closely. ########## lucene/core/src/java/org/apache/lucene/store/IOContext.java: ########## @@ -88,4 +84,18 @@ public IOContext(MergeInfo mergeInfo) { // Merges read input segments sequentially. this(Context.MERGE, mergeInfo, null, ReadAdvice.SEQUENTIAL); } + + /** + * Return an updated {@link IOContext} that has the provided {@link ReadAdvice} if the {@link + * Context} is a {@link Context#READ} context, otherwise return this existing instance. This helps + * preserve a {@link ReadAdvice#SEQUENTIAL} advice for merging, which is always the right choice, + * while allowing {@link IndexInput}s open for searching to use arbitrary {@link ReadAdvice}s. + */ + public IOContext toReadAdvice(ReadAdvice advice) { + if (context == Context.READ) { Review Comment: How should we deal with DEFAULT? I see lots of code using DEFAULT, so I would suggest: - Remove the enum constant altogether - Do the same like for READ I think DEFAULT is mostly used for writing, but I haven't checked closely. -- 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