thecoop commented on code in PR #16970:
URL: https://github.com/apache/lucene/pull/16970#discussion_r4468299228


##########
lucene/core/src/java/org/apache/lucene/store/IOContext.java:
##########
@@ -190,4 +200,23 @@ default IOContext union(FileOpenHint... hints) {
     Collections.addAll(merged, hints);
     return withHints(merged.toArray(FileOpenHint[]::new));
   }
+
+  /**
+   * Returns an IOContext with the given hints added to the ones it already 
has. A hint type that is
+   * already present is overridden by a hint of the same type passed in here.
+   *
+   * <p>Unlike {@link #union}, a hint of the same type as a given hint is 
replaced rather than
+   * rejected, and unlike {@link #withHints}, existing hints of other types 
are preserved.
+   *
+   * @throws IllegalArgumentException if two of the given hints are of the 
same type
+   */
+  default IOContext overrideHints(FileOpenHint... hints) {
+    Set<Class<?>> overridden =
+        Arrays.stream(hints).map(Object::getClass).collect(Collectors.toSet());
+    return withHints(

Review Comment:
   I think this would be clearer with a mutable list you `removeIf` and 
`addAll` to



-- 
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]

Reply via email to