cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/2] cassandra git commit: Avoid building PartitionUpdate in toString()
Date Tue, 22 Dec 2015 16:47:37 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 9a27d3fab -> e1cb9b48f


Avoid building PartitionUpdate in toString()

Patch by Tyler Hobbs; reviewed by Benjamin Lerer for CASSANDRA-10897


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/270e9862
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/270e9862
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/270e9862

Branch: refs/heads/trunk
Commit: 270e986264392b1ea10689768dcbb9403e449fd9
Parents: f967257
Author: Tyler Hobbs <tylerlhobbs@gmail.com>
Authored: Tue Dec 22 10:46:26 2015 -0600
Committer: Tyler Hobbs <tylerlhobbs@gmail.com>
Committed: Tue Dec 22 10:46:26 2015 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../db/partitions/PartitionUpdate.java          | 22 ++++++++++++++++++++
 2 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/270e9862/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index ff139c4..e83e46e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.3
+ * Avoid building PartitionUpdate in toString (CASSANDRA-10897)
  * Reduce heap spent when receiving many SSTables (CASSANDRA-10797)
  * Add back support for 3rd party auth providers to bulk loader (CASSANDRA-10873)
  * Eliminate the dependency on jgrapht for UDT resolution (CASSANDRA-10653)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/270e9862/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java b/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java
index 52f8f67..f10b3b6 100644
--- a/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java
+++ b/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java
@@ -581,6 +581,28 @@ public class PartitionUpdate extends AbstractBTreePartition
         isBuilt = true;
     }
 
+    @Override
+    public String toString()
+    {
+        if (isBuilt)
+            return super.toString();
+
+        // We intentionally override AbstractBTreePartition#toString() to avoid iterating
over the rows in the
+        // partition, which can result in build() being triggered and lead to errors if the
PartitionUpdate is later
+        // modified.
+
+        StringBuilder sb = new StringBuilder();
+        sb.append(String.format("[%s.%s] key=%s columns=%s",
+                                metadata.ksName,
+                                metadata.cfName,
+                                metadata.getKeyValidator().getString(partitionKey().getKey()),
+                                columns()));
+
+        sb.append("\n    deletionInfo=").append(deletionInfo);
+        sb.append(" (not built)");
+        return sb.toString();
+    }
+
     public static class PartitionUpdateSerializer
     {
         public void serialize(PartitionUpdate update, DataOutputPlus out, int version) throws
IOException


Mime
View raw message