maedhroz commented on code in PR #4428:
URL: https://github.com/apache/cassandra/pull/4428#discussion_r2538958083


##########
src/java/org/apache/cassandra/service/reads/tracked/TrackedLocalReads.java:
##########
@@ -145,6 +149,30 @@ private void beginReadInternal(
         ReadReconciliations.instance.acceptLocalSummary(readId, 
secondarySummary, summaryNodes);
     }
 
+    private static MutationSummary merge(Iterator<ShortMutationId> 
activationIds, MutationSummary summary)
+    {
+        if (activationIds == null || !activationIds.hasNext())
+            return summary;
+
+        MutationSummary.Builder builder = new 
MutationSummary.Builder(summary.tableId());
+
+        // TODO: Make faster without a copy
+        for (int i = 0; i < summary.size(); i++)
+        {
+            MutationSummary.CoordinatorSummary coordinatorSummary = 
summary.get(i);
+            MutationSummary.CoordinatorSummary.Builder 
coordinatorSummaryBuilder = builder.builderForLog(coordinatorSummary.logId());
+            
coordinatorSummaryBuilder.unreconciled.addAll(coordinatorSummary.unreconciled);
+            
coordinatorSummaryBuilder.reconciled.addAll(coordinatorSummary.reconciled);
+        }
+
+        while (activationIds.hasNext())
+        {
+            ShortMutationId id = activationIds.next();
+            builder.builderForLog(id).unreconciled.add(id.offset());

Review Comment:
   nit: What if we Just have `merge()` take a `Set` for `activationIds`? I'm 
not sure the iterator buys us anything. (I was going to say that might let us 
create a new `addAll()` in `AbstractMutable`, but each ID could have a 
different builder I guess. It just sucks, because we might double the size of 
the array in `add()`.)



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