cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject git commit: Avoid serializing keyspace redundantly in RowMutation patch by jbellis; reviewed by vijay for CASSANDRA-5458
Date Fri, 12 Apr 2013 02:07:09 GMT
Updated Branches:
  refs/heads/trunk 0c7141ee8 -> f04359d91


Avoid serializing keyspace redundantly in RowMutation
patch by jbellis; reviewed by vijay for CASSANDRA-5458


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

Branch: refs/heads/trunk
Commit: f04359d91ae3ea3adca6e13f74a7c54e3845cab7
Parents: 0c7141e
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Apr 11 21:06:28 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Apr 11 21:06:28 2013 -0500

----------------------------------------------------------------------
 src/java/org/apache/cassandra/db/RowMutation.java |   22 ++++++++++++---
 1 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f04359d9/src/java/org/apache/cassandra/db/RowMutation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RowMutation.java b/src/java/org/apache/cassandra/db/RowMutation.java
index dcc62c5..ef63027 100644
--- a/src/java/org/apache/cassandra/db/RowMutation.java
+++ b/src/java/org/apache/cassandra/db/RowMutation.java
@@ -69,7 +69,7 @@ public class RowMutation implements IMutation
 
     public RowMutation(ByteBuffer key, ColumnFamily cf)
     {
-        this(Schema.instance.getCFMetaData(cf.id()).ksName, key, cf);
+        this(cf.metadata().ksName, key, cf);
     }
 
     public String getTable()
@@ -239,13 +239,15 @@ public class RowMutation implements IMutation
     {
         public void serialize(RowMutation rm, DataOutput out, int version) throws IOException
         {
-            out.writeUTF(rm.getTable());
+            if (version < MessagingService.VERSION_20)
+                out.writeUTF(rm.getTable());
+
             ByteBufferUtil.writeWithShortLength(rm.key(), out);
 
             /* serialize the modifications in the mutation */
             int size = rm.modifications.size();
             out.writeInt(size);
-            assert size >= 0;
+            assert size > 0;
             for (Map.Entry<UUID, ColumnFamily> entry : rm.modifications.entrySet())
             {
                 if (version < MessagingService.VERSION_12)
@@ -256,15 +258,20 @@ public class RowMutation implements IMutation
 
         public RowMutation deserialize(DataInput in, int version, ColumnSerializer.Flag flag)
throws IOException
         {
-            String table = in.readUTF();
+            String table = null; // will always be set from cf.metadata but javac isn't smart
enough to see that
+            if (version < MessagingService.VERSION_20)
+                table = in.readUTF();
+
             ByteBuffer key = ByteBufferUtil.readWithShortLength(in);
             int size = in.readInt();
+            assert size > 0;
 
             Map<UUID, ColumnFamily> modifications;
             if (size == 1)
             {
                 ColumnFamily cf = deserializeOneCf(in, version, flag);
                 modifications = Collections.singletonMap(cf.id(), cf);
+                table = cf.metadata().ksName;
             }
             else
             {
@@ -273,6 +280,7 @@ public class RowMutation implements IMutation
                 {
                     ColumnFamily cf = deserializeOneCf(in, version, flag);
                     modifications.put(cf.id(), cf);
+                    table = cf.metadata().ksName;
                 }
             }
 
@@ -298,7 +306,11 @@ public class RowMutation implements IMutation
         public long serializedSize(RowMutation rm, int version)
         {
             TypeSizes sizes = TypeSizes.NATIVE;
-            int size = sizes.sizeof(rm.getTable());
+            int size = 0;
+
+            if (version < MessagingService.VERSION_20)
+                size += sizes.sizeof(rm.getTable());
+
             int keySize = rm.key().remaining();
             size += sizes.sizeof((short) keySize) + keySize;
 


Mime
View raw message