dcapwell commented on code in PR #30:
URL: https://github.com/apache/cassandra-accord/pull/30#discussion_r1136276809


##########
accord-core/src/main/java/accord/utils/async/AsyncChains.java:
##########
@@ -423,6 +424,16 @@ public static <V> AsyncChain<V> reduce(AsyncChain<V> a, 
AsyncChain<V> b, BiFunct
         return new Reduce<>(Lists.newArrayList(a, b), reducer);
     }
 
+    public static <A, B> AsyncChain<B> reduce(List<? extends AsyncChain<? 
extends A>> chains, B zero, BiFunction<B, ? super A, B> reducer)
+    {
+        switch (chains.size())
+        {
+            case 0: return AsyncChains.success(zero);
+            case 1: return chains.get(0).map(a -> reducer.apply(zero, a));
+        }
+        return new ReduceWithZero<>(chains, zero, reducer);

Review Comment:
   fair, we know it has 2, I think I did this trying to find a way to merge 
`Reduce` to handle both cases but after awhile I migrated to use its own class; 
ill simplify



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