You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by mc...@apache.org on 2020/01/10 10:44:39 UTC

[cassandra] branch cassandra-3.0 updated: Include updates to static column in mutation size calculations

This is an automated email from the ASF dual-hosted git repository.

mck pushed a commit to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-3.0 by this push:
     new c2f201f  Include updates to static column in mutation size calculations
c2f201f is described below

commit c2f201f147029c044b7a1f774cba7b6ab615945e
Author: Vincent White <vi...@instaclustr.com>
AuthorDate: Mon Aug 26 03:38:52 2019 +0000

    Include updates to static column in mutation size calculations
    
     patch by Vincent White; reviewed by Mick Semb Wever for CASSANDRA-15293
---
 CHANGES.txt                                         |  1 +
 .../cassandra/db/partitions/PartitionUpdate.java    |  9 +++++++++
 .../cassandra/db/partition/PartitionUpdateTest.java | 21 +++++++++++++++++++++
 3 files changed, 31 insertions(+)

diff --git a/CHANGES.txt b/CHANGES.txt
index 44719b4..620eb35 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.20
+ * Include updates to static column in mutation size calculations (CASSANDRA-15293)
  * Fix point-in-time recoevery ignoring timestamp of updates to static columns (CASSANDRA-15292)
  * GC logs are also put under $CASSANDRA_LOG_DIR (CASSANDRA-14306)
  * Fix sstabledump's position key value when partitions have multiple rows (CASSANDRA-14721)
diff --git a/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java b/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java
index 5f74780..f476f5b 100644
--- a/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java
+++ b/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java
@@ -372,6 +372,15 @@ public class PartitionUpdate extends AbstractBTreePartition
     public int dataSize()
     {
         int size = 0;
+
+        if (holder.staticRow != null)
+        {
+            for (ColumnData cd : holder.staticRow.columnData())
+            {
+                size += cd.dataSize();
+            }
+        }
+
         for (Row row : this)
         {
             size += row.clustering().dataSize();
diff --git a/test/unit/org/apache/cassandra/db/partition/PartitionUpdateTest.java b/test/unit/org/apache/cassandra/db/partition/PartitionUpdateTest.java
index a069db1..7dff91f 100644
--- a/test/unit/org/apache/cassandra/db/partition/PartitionUpdateTest.java
+++ b/test/unit/org/apache/cassandra/db/partition/PartitionUpdateTest.java
@@ -52,6 +52,27 @@ public class PartitionUpdateTest extends CQLTester
     }
 
     @Test
+    public void testMutationSize()
+    {
+        createTable("CREATE TABLE %s (key text, clustering int, a int, s int static, PRIMARY KEY(key, clustering))");
+        CFMetaData cfm = currentTableMetadata();
+
+        PartitionUpdate update = new RowUpdateBuilder(cfm, FBUtilities.timestampMicros(), "key0").add("s", 1).buildUpdate();
+        int size1 = update.dataSize();
+        Assert.assertEquals(20, size1);
+
+        update = new RowUpdateBuilder(cfm, FBUtilities.timestampMicros(), "key0").clustering(1).add("a", 2).buildUpdate();
+        int size2 = update.dataSize();
+        Assert.assertTrue(size1 != size2);
+
+        update = new RowUpdateBuilder(cfm, FBUtilities.timestampMicros(), "key0").buildUpdate();
+        int size3 = update.dataSize();
+        Assert.assertTrue(size1 != size3);
+        Assert.assertTrue(size2 != size3);
+
+    }
+
+    @Test
     public void testOperationCountWithCompactTable()
     {
         createTable("CREATE TABLE %s (key text PRIMARY KEY, a int) WITH COMPACT STORAGE");


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org