JoergBudi commented on PR #628:
URL: 
https://github.com/apache/commons-collections/pull/628#issuecomment-3146796903

   @ppkarwasz: Thx for your feeback, my thoughts:
   The JDK samples don't invite a nested/chained usage as much as the 4 
functions in SetUtils do.
   It is also hard to explain, that 5 chainings are fine, 40 are disastrous, 
and everything
   in between is just unexpectingly expensive.
   For many usecases, from a logical point of view, it doesn't matter if views 
or intermediate sets are used,
   and as developers tend to lazyness, it will be hard to convince them in 
javadoc to use
   the additional toSet() method when for low number of iterations everything 
works fine. 
   
   Seeing the methods side-by-side, the API user is forced to think which 
method to use and is
   lured to check the javadoc of both methods, and that is a good thing here 
(when I have a look
   at the javadoc on this branch). 
   
   But I understand, that one can come to a different conclusion.
   I am happy to transform this PR to a javadoc-only-PR, but a short guidance
   would then be good. I would suggest, to update all 4 methods with paragraph 
similar to this:
   
   --
   Note: Chaining/Nesting the SetView result of a union() invocation as input 
into union(), difference(), disjunction(), intersection() 
         multiple times becomes expensive, to avoid this, use SetView#toSet() 
on each intermediate result when it 
         still suits your usecase.
   ---
   Would this be ok ?
   
   I got one thing to add:
   
   In case collections-722 (PR 628 which improves chaining the chainedIterator) 
gets merged,
   chaining via SetUtils.union( chainedSet, someOtherSet) as it is in this 
Testcase of this collections-838, is fast even
   for a high number of chainings.
   However doing it the other way round (SetUtils.union(someOtherSet, 
chainedSet)) suffers again from
   exponential growth, as I can't think of a good solution to optimize 
IteratorChain+FilterIterator +
   the 4 SetView implementations and the various predicates.
   This makes the expected chaining runtime behaviour even more challenging to 
understand
   as some invocations patterns don't lead to exponential growth.


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

Reply via email to