dcapwell commented on code in PR #2339:
URL: https://github.com/apache/cassandra/pull/2339#discussion_r1203126196


##########
src/java/org/apache/cassandra/service/accord/AccordCommandStore.java:
##########
@@ -252,6 +341,47 @@ public void completeOperation(AccordSafeCommandStore store,
         current = null;
     }
 
+    <O> O mapReduceForRange(Routables<?, ?> keysOrRanges, Ranges slice, 
BiFunction<CommandTimeseriesHolder, O, O> map, O accumulate, O terminalValue)
+    {
+        keysOrRanges = keysOrRanges.slice(slice, Routables.Slice.Minimal);
+        switch (keysOrRanges.domain())
+        {
+            case Key:
+            {
+                AbstractKeys<Key, ?> keys = (AbstractKeys<Key, ?>) 
keysOrRanges;
+                for (CommandTimeseriesHolder summary : 
commandsForRanges.search(keys))
+                {
+                    accumulate = map.apply(summary, accumulate);
+                    if (accumulate.equals(terminalValue))
+                        return accumulate;
+                }
+            }
+            break;
+            case Range:
+            {
+                AbstractRanges<?> ranges = (AbstractRanges<?>) keysOrRanges;
+                for (Range range : ranges)
+                {
+                    CommandTimeseriesHolder summary = 
commandsForRanges.search(range);
+                    if (summary == null)
+                        continue;
+                    accumulate = map.apply(summary, accumulate);
+                    if (accumulate.equals(terminalValue))
+                        return accumulate;
+                }
+            }
+            break;
+            default:
+                throw new AssertionError("Unknown domain: " + 
keysOrRanges.domain());
+        }
+        return accumulate;
+    }
+
+    CommandsForRanges.Builder unbuild()

Review Comment:
   switched to `update` and did a refactor that was in the back of my head; 
split `Builder` into 2: `Builder` and `Updater`...  one with a `build` method 
(for init) and one with `apply` which is for mutations



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