dcapwell commented on code in PR #30:
URL: https://github.com/apache/cassandra-accord/pull/30#discussion_r1136283769
##########
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:
trying to resolve this comment and I remember why it is needed; `zero` is
type `B` but the chains are of type `A`, so can not reduce without keeping the
`zero`
--
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]