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


##########
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:
   This is not ideal. I think the cleanest way is just to create a copy of the 
existing hints in a `HashSet` and add the new hints to it, then just use that



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