belliottsmith commented on code in PR #50:
URL: https://github.com/apache/cassandra-accord/pull/50#discussion_r1284881885


##########
accord-core/src/main/java/accord/local/CommandStores.java:
##########
@@ -474,40 +474,42 @@ public  <O> void mapReduceConsume(PreLoadContext context, 
IntStream commandStore
 
     public <O> AsyncChain<O> mapReduce(PreLoadContext context, Routables<?> 
keys, long minEpoch, long maxEpoch, MapReduce<? super SafeCommandStore, O> 
mapReduce)
     {
-        AsyncChain<O> chain = null;
         BiFunction<O, O, O> reducer = mapReduce::reduce;
         Snapshot snapshot = current;
         ShardHolder[] shards = snapshot.shards;
+        List<AsyncChain<? extends O>> chains = null;

Review Comment:
   Wouldn't a simpler solution have been
   
   ```
       abstract O complete(I[] results);
   ```
   
   and
    
   ```
           if (REMAINING.decrementAndGet(this) == 0)
           {
               O combinedResult;
               try
               {
                   combinedResult = complete(results());
               }
               catch (Throwable t)
               {
                   callback.accept(null, t);
                   return;
               }
               callback.accept(combinedResult, null);
           }
   ```
   ?
   
   This also maintains the benefit of not encapsulating when there's only one 
async operation - which we expect to be the norm.



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