jimczi commented on code in PR #16682:
URL: https://github.com/apache/lucene/pull/16682#discussion_r4084401573
##########
lucene/core/src/java/org/apache/lucene/store/IOContext.java:
##########
@@ -142,13 +152,23 @@ default <T extends FileOpenHint> Stream<T> hints(Class<T>
cls) {
}
/**
- * Returns an IOContext with the given hints, if it makes sense to do so for
this specific
- * context. Otherwise, returns this context.
+ * Returns an IOContext with the given hints.
*
* <p>The returned context has the same {@link #context()}, {@link
#mergeInfo()}, and {@link
* #flushInfo()} as this context.
*
* <p>This instance is immutable and unaffected by this method call.
*/
IOContext withHints(FileOpenHint... hints);
+
+ /**
+ * Returns an IOContext with the given hints added to the ones it already
has. A hint it already
+ * has is added once.
+ *
+ * @throws IllegalArgumentException if that would give it two different
hints of the same type
+ */
+ default IOContext union(FileOpenHint... hints) {
+ return withHints(
+ Stream.concat(hints().stream(),
Stream.of(hints)).distinct().toArray(FileOpenHint[]::new));
Review Comment:
Done.
##########
lucene/core/src/java/org/apache/lucene/store/NoReuseHint.java:
##########
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.store;
+
+/**
+ * A hint that reads of the file do not come back to the same parts of it. A
writer sets it for a
+ * file that is read that way once written.
Review Comment:
Good catch, the old wording claimed more than we want. A file can be read
over and over and still not be worth keeping in memory. What it's missing is
reuse a cache can exploit, either because the reads land in no usable pattern
or because the file is big enough next to the rest of the index that holding it
evicts things that do benefit. I reworded it along those lines.
--
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]