gsmiller commented on code in PR #15823:
URL: https://github.com/apache/lucene/pull/15823#discussion_r2985032890


##########
lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java:
##########
@@ -174,6 +176,36 @@ public void addAll(Collection<T> elements) {
     }
   }
 
+  /**
+   * Similar to {@link #addAll(Collection)}, but supply an {@link Function} to 
transform element.
+   * This method should be preferred over calling {@link #addAll(Collection)}, 
when the type of
+   * param elements is different from the type of this {@link PriorityQueue}, 
since it doesn't
+   * require the caller to do the conversion at the call site.
+   */
+  public <S> void addAll(Collection<S> elements, Function<S, T> 
elementTransformer) {

Review Comment:
   So I think the proposed idea is a little different actually. The idea would 
be for this method signature to simply be:
   `public void addAll(Iterable<T> elements)`.
   
   Then, from your calling code in DisjunctionMaxBulkScorer, you'd call like 
this:
   `this.scorers.addAll(Iterables.transform(scorers, BulkScorerAndNext::new));`
   
   The goal is that PriorityQueue doesn't need to know anything about the 
translation logic. That all gets encapsulated behind the Iterator that is setup 
by the calling code. WDYT?



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