gsmiller commented on PR #15823: URL: https://github.com/apache/lucene/pull/15823#issuecomment-4143128954
Thanks for the iteration! I also like where this change has evolved. @uschindler - I don't completely follow your comment about addAll only working on a newly-constructed/empty heap. Can you elaborate a bit? I believe both of the addAll methods (existing and this proposed one) should work correctly on a heap that already contains some elements, but I might be missing something? Or maybe I'm misunderstanding your point? Oh wait, after re-reading, maybe you're describing a different option that would appropriately size a new heap for a provided stream? One that would handle the overflow case by essentially allocating a bigger PQ? One thing that jumps out to me: The Stream-based and Collection-based addAll methods are inconsistent with how they handle the overflow/error case. The existing, Collection-based implementation won't add anything if it would overflow the PQ (so the PQ instance stayed unchanged on an invalid call). The Stream-based version best-effort adds until it discovers an overflow, then ensures the heap invariant with the finally block. This behavior makes sense to me for the Stream-based version—it's essentially all we can do since we don't know the size up-front. But it makes me wonder if we should change the Collection-based version to be consistent, and add what's possible, maintain the heap invariant, then throw. Oh, and +1 to the try/catch paradigm vs. using #limit and silently failing to add everything. Thanks again! -- 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]
