cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject [1/3] cassandra git commit: Small optimisation to Columns subset serialization
Date Fri, 21 Aug 2015 16:41:12 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 0ad1e0aaf -> f60322a71
  refs/heads/trunk 34b893aff -> 14c1d6298


Small optimisation to Columns subset serialization

It is possible to disambiguate the small serialization
format from the large with fewer bytes. Prior to this patch
we serialized -1L for the small coding bitmap, however this
value can instead by the column size delta, and it is entirely
consistent: zero means no columns missing in both formats;
if any are missing, we use the size of the superset to decide.


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

Branch: refs/heads/cassandra-3.0
Commit: f60322a7171d7be10a16f282f9437e695eda89fa
Parents: 0ad1e0a
Author: Benedict Elliott Smith <benedict@apache.org>
Authored: Wed Aug 19 13:02:05 2015 +0100
Committer: Benedict Elliott Smith <benedict@apache.org>
Committed: Fri Aug 21 17:11:16 2015 +0100

----------------------------------------------------------------------
 src/java/org/apache/cassandra/db/Columns.java | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f60322a7/src/java/org/apache/cassandra/db/Columns.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Columns.java b/src/java/org/apache/cassandra/db/Columns.java
index 0b29830..f217fd7 100644
--- a/src/java/org/apache/cassandra/db/Columns.java
+++ b/src/java/org/apache/cassandra/db/Columns.java
@@ -484,13 +484,13 @@ public class Columns implements Iterable<ColumnDefinition>
         public Columns deserializeSubset(Columns superset, DataInputPlus in) throws IOException
         {
             long encoded = in.readUnsignedVInt();
-            if (encoded == -1L)
+            if (encoded == 0L)
             {
-                return deserializeLargeSubset(in, superset);
+                return superset;
             }
-            else if (encoded == 0L)
+            else if (superset.columnCount() >= 64)
             {
-                return superset;
+                return deserializeLargeSubset(in, superset, (int) encoded);
             }
             else
             {
@@ -540,7 +540,6 @@ public class Columns implements Iterable<ColumnDefinition>
         private void serializeLargeSubset(Columns columns, int columnCount, Columns superset,
int supersetCount, DataOutputPlus out) throws IOException
         {
             // write flag indicating we're in lengthy mode
-            out.writeUnsignedVInt(-1L);
             out.writeUnsignedVInt(supersetCount - columnCount);
             BTreeSearchIterator<ColumnDefinition, ColumnDefinition> iter = superset.iterator();
             if (columnCount < supersetCount / 2)
@@ -571,10 +570,9 @@ public class Columns implements Iterable<ColumnDefinition>
         }
 
         @DontInline
-        private Columns deserializeLargeSubset(DataInputPlus in, Columns superset) throws
IOException
+        private Columns deserializeLargeSubset(DataInputPlus in, Columns superset, int delta)
throws IOException
         {
             int supersetCount = superset.columnCount();
-            int delta = (int) in.readUnsignedVInt();
             int columnCount = supersetCount - delta;
 
             BTree.Builder<ColumnDefinition> builder = BTree.builder(Comparator.naturalOrder());
@@ -614,7 +612,7 @@ public class Columns implements Iterable<ColumnDefinition>
         private int serializeLargeSubsetSize(Columns columns, int columnCount, Columns superset,
int supersetCount)
         {
             // write flag indicating we're in lengthy mode
-            int size = TypeSizes.sizeofUnsignedVInt(-1L) + TypeSizes.sizeofUnsignedVInt(supersetCount
- columnCount);
+            int size = TypeSizes.sizeofUnsignedVInt(supersetCount - columnCount);
             BTreeSearchIterator<ColumnDefinition, ColumnDefinition> iter = superset.iterator();
             if (columnCount < supersetCount / 2)
             {


Mime
View raw message