jpountz commented on code in PR #13219:
URL: https://github.com/apache/lucene/pull/13219#discussion_r1539310893
##########
lucene/codecs/src/java/org/apache/lucene/codecs/blockterms/VariableGapTermsIndexReader.java:
##########
@@ -53,7 +54,7 @@ public VariableGapTermsIndexReader(SegmentReadState state)
throws IOException {
state.segmentInfo.name,
state.segmentSuffix,
VariableGapTermsIndexWriter.TERMS_INDEX_EXTENSION);
- final IndexInput in = state.directory.openInput(fileName,
state.context.toReadOnce());
+ final IndexInput in = state.directory.openInput(fileName,
IOContext.READONCE);
Review Comment:
A change to this class wouldn't be necessary anymore once #13216 is merged.
##########
lucene/core/src/java/org/apache/lucene/store/IOContext.java:
##########
@@ -54,58 +43,74 @@ public enum Context {
DEFAULT
};
- public static final IOContext DEFAULT = new IOContext(Context.DEFAULT);
+ /** Advice regarding the read access pattern. */
+ public enum ReadAdvice {
+ /**
+ * Normal behavior. Data is expected to be read mostly sequentially. The
system is expected to
+ * cache the hottest pages.
+ */
+ NORMAL,
+ /**
+ * Data is expected to be read in a random-access fashion, either by {@link
+ * IndexInput#seek(long) seeking} often and reading relatively short
sequences of bytes at once,
+ * or by reading data through the {@link RandomAccessInput} abstraction in
random order.
+ */
+ RANDOM,
+ /** Data is expected to be read sequentially with very little seeking at
most. */
+ SEQUENTIAL,
+ /**
+ * Data is treated as random-access memory in practice. {@link Directory}
implementations may
+ * explicitly load the content of the file in memory, or provide hints to
the system so that it
+ * loads the content of the file into the page cache at open time. This
should only be used on
+ * very small files that can be expected to fit in RAM with very high
confidence.
+ */
+ LOAD
+ }
+
+ public static final IOContext DEFAULT =
+ new IOContext(Context.DEFAULT, null, null, ReadAdvice.NORMAL);
- public static final IOContext READONCE = new IOContext(true, false, false);
+ public static final IOContext READONCE = new
IOContext(ReadAdvice.SEQUENTIAL);
- public static final IOContext READ = new IOContext(false, false, false);
+ public static final IOContext READ = new IOContext(ReadAdvice.NORMAL);
- public static final IOContext LOAD = new IOContext(false, true, true);
+ public static final IOContext LOAD = new IOContext(ReadAdvice.LOAD);
- public static final IOContext RANDOM = new IOContext(false, false, true);
+ public static final IOContext RANDOM = new IOContext(ReadAdvice.RANDOM);
Review Comment:
FWIW kept these constant names as-is rather than align them with
`ReadAdvice` constant names on purpose as they convey stronger expectations.
##########
lucene/core/src/java/org/apache/lucene/store/IOContext.java:
##########
@@ -54,58 +43,74 @@ public enum Context {
DEFAULT
};
- public static final IOContext DEFAULT = new IOContext(Context.DEFAULT);
+ /** Advice regarding the read access pattern. */
+ public enum ReadAdvice {
+ /**
+ * Normal behavior. Data is expected to be read mostly sequentially. The
system is expected to
+ * cache the hottest pages.
+ */
+ NORMAL,
+ /**
+ * Data is expected to be read in a random-access fashion, either by {@link
+ * IndexInput#seek(long) seeking} often and reading relatively short
sequences of bytes at once,
+ * or by reading data through the {@link RandomAccessInput} abstraction in
random order.
+ */
+ RANDOM,
+ /** Data is expected to be read sequentially with very little seeking at
most. */
+ SEQUENTIAL,
+ /**
+ * Data is treated as random-access memory in practice. {@link Directory}
implementations may
+ * explicitly load the content of the file in memory, or provide hints to
the system so that it
+ * loads the content of the file into the page cache at open time. This
should only be used on
+ * very small files that can be expected to fit in RAM with very high
confidence.
+ */
+ LOAD
Review Comment:
I wonder if there's a better name for this that is more aligned with other
constant names. `RANDOM_ACCESS_MEMORY`?
--
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]