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


##########
src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java:
##########
@@ -466,6 +466,56 @@ public List<CounterMark> collectCounterMarks()
         return marks;
     }
 
+    /**
+     *
+     * @return the estimated number of rows affected by this mutation 
+     */
+    public int affectedRowCount()
+    {
+        // If there is a partition-level deletion, we intend to delete at 
least one row.
+        if (!partitionLevelDeletion().isLive())
+            return 1;
+
+        int count = 0;
+
+        // Each range delete should correspond to at least one intended row 
deletion.
+        if (deletionInfo().hasRanges())
+            count += deletionInfo().rangeCount();
+
+        count += rowCount();
+
+        return count;
+    }
+
+    /**
+     *
+     * @return the estimated total number of columns that either have live 
data or are covered by a delete
+     */
+    public int affectedColumnCount()
+    {
+        // If there is a partition-level deletion, we intend to delete at 
least the columns of one row.
+        if (!partitionLevelDeletion().isLive())
+            return metadata().regularAndStaticColumns().size();
+
+        int count = 0;
+
+        // Each range delete should correspond to at least one intended row 
deletion, and with it, its regular columns.
+        if (deletionInfo().hasRanges())
+            count += deletionInfo().rangeCount() * 
metadata().regularColumns().size();

Review Comment:
   I'm not 100% sure on counters. They are just regular columns, correct? 
(Going up a level, this is really a pretty conservative lower bound estimate, 
given range deletes can delete more than one row. There just isn't a way to 
figure that out without actually doing a read, etc.)
   
   Good catch on the statics. They wouldn't be covered by range deletes, but 
I'm still not accounting for them properly in either `affectedRowCount()` or 
`affectedColumnCount()`. Working on a couple new tests, and should have 
something up shortly...



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