netudima commented on code in PR #4795:
URL: https://github.com/apache/cassandra/pull/4795#discussion_r3237154609


##########
src/java/org/apache/cassandra/db/rows/Row.java:
##########
@@ -778,22 +784,51 @@ public Row merge(DeletionTime activeDeletion)
             if (activeDeletion.deletes(rowInfo))
                 rowInfo = LivenessInfo.EMPTY;
 
+            int columnsCountEstimation = 0;
             for (Row row : rows)
-                columnDataIterators.add(row == null ? 
Collections.emptyIterator() : row.iterator());
+            {
+                if (row != null)
+                {
+                    columnDataIterators.add(row.iterator());
+                    columnsCountEstimation = Math.max(columnsCountEstimation, 
row.columnCount());
+                }
+                else
+                {
+                    columnDataIterators.add(Collections.emptyIterator());
+                }
+            }
+            // try to estimate and set a potential target capacity
+            if (dataBuffer.length < columnsCountEstimation)
+                dataBuffer = Arrays.copyOf(dataBuffer, columnsCountEstimation);

Review Comment:
   it was more to preserve the original behaviour during a refactoring (when an 
array list is extending but not clearing), let me check if 
org.apache.cassandra.db.rows.Row.Merger#merge can be invoked more than once 
without cleanup (I suppose the an initial expectation - it must not)



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