cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Avoids double serialization of cfId in RM messages
Date Tue, 29 May 2012 19:49:35 GMT
Updated Branches:
  refs/heads/trunk f4f9802c4 -> b4d94c0e7


Avoids double serialization of cfId in RM messages

patch by slebresne; reviewed by jbellis for CASSANDRA-4293


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

Branch: refs/heads/trunk
Commit: b4d94c0e7c639d9572623af81cf2b9a0076a5bfa
Parents: f4f9802
Author: Sylvain Lebresne <sylvain@riptano.com>
Authored: Tue May 29 21:44:54 2012 +0200
Committer: Sylvain Lebresne <sylvain@riptano.com>
Committed: Tue May 29 21:44:54 2012 +0200

----------------------------------------------------------------------
 CHANGES.txt                                       |    2 ++
 src/java/org/apache/cassandra/db/RowMutation.java |   14 ++++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b4d94c0e/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b36b736..888b3f6 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -10,6 +10,8 @@
  * Improve MessagingService efficiency (CASSANDRA-3617)
  * Avoid ID conflicts from concurrent schema changes (CASSANDRA-3794)
  * Set thrift HSHA server thread limit to unlimet by default (CASSANDRA-4277)
+ * Avoids double serialization of CF id in RowMutation messages
+   (CASSANDRA-4293)
 
 
 1.1.1-dev

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b4d94c0e/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 0d83cec..1bce73b 100644
--- a/src/java/org/apache/cassandra/db/RowMutation.java
+++ b/src/java/org/apache/cassandra/db/RowMutation.java
@@ -415,7 +415,8 @@ public class RowMutation implements IMutation
             assert size >= 0;
             for (Map.Entry<UUID, ColumnFamily> entry : rm.modifications.entrySet())
             {
-                ColumnFamily.serializer.serializeCfId(entry.getKey(), dos, version);
+                if (version < MessagingService.VERSION_12)
+                    ColumnFamily.serializer.serializeCfId(entry.getKey(), dos, version);
                 ColumnFamily.serializer.serialize(entry.getValue(), dos, version);
             }
         }
@@ -428,9 +429,13 @@ public class RowMutation implements IMutation
             int size = dis.readInt();
             for (int i = 0; i < size; ++i)
             {
-                UUID cfId = ColumnFamily.serializer.deserializeCfId(dis, version);
+                // We used to uselessly write the cf id here
+                if (version < MessagingService.VERSION_12)
+                    ColumnFamily.serializer.deserializeCfId(dis, version);
                 ColumnFamily cf = ColumnFamily.serializer.deserialize(dis, flag, TreeMapBackedSortedColumns.factory(),
version);
-                modifications.put(cfId, cf);
+                // We don't allow RowMutation with null column family, so we should never
get null back.
+                assert cf != null;
+                modifications.put(cf.id(), cf);
             }
             return new RowMutation(table, key, modifications);
         }
@@ -450,7 +455,8 @@ public class RowMutation implements IMutation
             size += sizes.sizeof(rm.modifications.size());
             for (Map.Entry<UUID,ColumnFamily> entry : rm.modifications.entrySet())
             {
-                size += ColumnFamily.serializer.cfIdSerializedSize(entry.getValue().id(),
sizes, version);
+                if (version < MessagingService.VERSION_12)
+                    size += ColumnFamily.serializer.cfIdSerializedSize(entry.getValue().id(),
sizes, version);
                 size += ColumnFamily.serializer.serializedSize(entry.getValue(), TypeSizes.NATIVE,
version);
             }
 


Mime
View raw message