gsmiller commented on code in PR #15823:
URL: https://github.com/apache/lucene/pull/15823#discussion_r2988354176
##########
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:
I wonder how important that validation is. It's an exceptional case (the
caller really shouldn't be overflowing their PQ capacity). We'll hit the same
AIOOB exception anyway in the for-each loop that's populating the array, so the
outcome is really the same if you overflow the capacity, so I'm not sure that
early check adds a ton of value. It's nice to do up-front, but I don't think
I'd design the API around it. So I guess I don't think it's a problem to remove
this up-front sizing check, but maybe you're considering something I'm not? Do
you think it's critical? Thanks again for iterating!
--
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]