jpountz commented on code in PR #13998:
URL: https://github.com/apache/lucene/pull/13998#discussion_r1850224848
##########
lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInput.java:
##########
@@ -406,6 +406,15 @@ void advise(long offset, long length,
IOConsumer<MemorySegment> advice) throws I
}
}
+ public Optional<Boolean> isLoaded() {
Review Comment:
Is it missing the `@Override` annotation?
##########
lucene/core/src/java/org/apache/lucene/store/IndexInput.java:
##########
@@ -226,4 +227,17 @@ public String toString() {
* @param length the number of bytes to prefetch
*/
public void prefetch(long offset, long length) throws IOException {}
+
+ /**
+ * Returns a hint whether all the contents of this input are resident in
physical memory. It's a
+ * hint because the operating system may have paged out some of the data by
the time this method
+ * returns. If the optional is true, then it's likely that the contents of
this input are resident
+ * in physical memory. A value of false does not imply that the contents are
not resident in
+ * physical memory. An empty optional is returned if it is not possible to
determine.
Review Comment:
It looks like an empty optional and `false` mostly mean the same thing,
which makes me wonder if this should return a `boolean` directly?
It may also be worth pointing out that this method runs in linear time with
the amount of data that this `IndexInput` exposes (as opposed to
constant-time). So it makes little sense to use it to do something like "if
(isLoaded() == false) { prefetch(); }"
--
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]