cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject cassandra git commit: Fix CFMetaData ids serialization
Date Tue, 21 Jul 2015 14:05:23 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk a66863861 -> 6249a3b1e


Fix CFMetaData ids serialization

patch by slebresne; reviewed by iamaleksey for CASSANDRA-9848


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

Branch: refs/heads/trunk
Commit: 6249a3b1e6f9f758cbdbd79ffc775e10874b3a56
Parents: a668638
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Mon Jul 20 12:12:46 2015 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Tue Jul 21 16:04:41 2015 +0200

----------------------------------------------------------------------
 CHANGES.txt                                       |  2 +-
 .../org/apache/cassandra/config/CFMetaData.java   | 18 +++++-------------
 .../org/apache/cassandra/db/ReadResponse.java     |  2 +-
 .../partitions/UnfilteredPartitionIterators.java  |  4 ++--
 .../db/rows/UnfilteredRowIteratorSerializer.java  |  5 +++--
 .../apache/cassandra/utils/UUIDSerializer.java    |  2 +-
 6 files changed, 13 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6249a3b1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1f33e6c..1828476 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,7 +2,7 @@
  * Metrics should use up to date nomenclature (CASSANDRA-9448)
  * Change CREATE/ALTER TABLE syntax for compression (CASSANDRA-8384)
  * Cleanup crc and adler code for java 8 (CASSANDRA-9650)
- * Storage engine refactor (CASSANDRA-8099, 9743, 9746, 9759, 9781, 9808, 9825)
+ * Storage engine refactor (CASSANDRA-8099, 9743, 9746, 9759, 9781, 9808, 9825, 9848)
  * Update Guava to 18.0 (CASSANDRA-9653)
  * Bloom filter false positive ratio is not honoured (CASSANDRA-8413)
  * New option for cassandra-stress to leave a ratio of columns null (CASSANDRA-9522)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6249a3b1/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java
index 6c53699..3b43960 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -17,7 +17,6 @@
  */
 package org.apache.cassandra.config;
 
-import java.io.DataInput;
 import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -49,6 +48,7 @@ import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.io.compress.CompressionParameters;
 import org.apache.cassandra.io.compress.LZ4Compressor;
+import org.apache.cassandra.io.util.DataInputPlus;
 import org.apache.cassandra.io.util.DataOutputPlus;
 import org.apache.cassandra.schema.SchemaKeyspace;
 import org.apache.cassandra.schema.Triggers;
@@ -1507,23 +1507,16 @@ public final class CFMetaData
         }
     }
 
-    // We don't use UUIDSerializer below because we want to use this with vint-encoded streams
and UUIDSerializer
-    // currently assumes a NATIVE encoding. This is also why we don't use writeLong()/readLong
in the methods below:
-    // this would encode the values, but by design of UUID it is likely that both long will
be very big numbers
-    // and so we have a fair change that the encoding will take more than 16 bytes which
is not desirable. Note that
-    // we could make UUIDSerializer work as the serializer below, but I'll keep that to later.
     public static class Serializer
     {
         public void serialize(CFMetaData metadata, DataOutputPlus out, int version) throws
IOException
         {
-            // for some reason these are stored is LITTLE_ENDIAN; so just reverse them
-            out.writeLong(Long.reverseBytes(metadata.cfId.getMostSignificantBits()));
-            out.writeLong(Long.reverseBytes(metadata.cfId.getLeastSignificantBits()));
+            UUIDSerializer.serializer.serialize(metadata.cfId, out, version);
         }
 
-        public CFMetaData deserialize(DataInput in, int version) throws IOException
+        public CFMetaData deserialize(DataInputPlus in, int version) throws IOException
         {
-            UUID cfId = new UUID(Long.reverseBytes(in.readLong()), Long.reverseBytes(in.readLong()));
+            UUID cfId = UUIDSerializer.serializer.deserialize(in, version);
             CFMetaData metadata = Schema.instance.getCFMetaData(cfId);
             if (metadata == null)
             {
@@ -1538,8 +1531,7 @@ public final class CFMetaData
 
         public long serializedSize(CFMetaData metadata, int version)
         {
-            // We've made sure it was encoded as 16 bytes whatever the TypeSizes is.
-            return 16;
+            return UUIDSerializer.serializer.serializedSize(metadata.cfId, version);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6249a3b1/src/java/org/apache/cassandra/db/ReadResponse.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ReadResponse.java b/src/java/org/apache/cassandra/db/ReadResponse.java
index 6a61416..3737a38 100644
--- a/src/java/org/apache/cassandra/db/ReadResponse.java
+++ b/src/java/org/apache/cassandra/db/ReadResponse.java
@@ -116,7 +116,7 @@ public abstract class ReadResponse
         {
             try
             {
-                DataInput in = new DataInputStream(ByteBufferUtil.inputStream(data));
+                DataInputPlus in = new DataInputPlus.DataInputStreamPlus(ByteBufferUtil.inputStream(data));
                 return UnfilteredPartitionIterators.serializerForIntraNode().deserialize(in,
MessagingService.current_version, flag);
             }
             catch (IOException e)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6249a3b1/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java
b/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java
index 8b2ef03..0d3d364 100644
--- a/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java
+++ b/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java
@@ -17,7 +17,6 @@
  */
 package org.apache.cassandra.db.partitions;
 
-import java.io.DataInput;
 import java.io.IOError;
 import java.io.IOException;
 import java.nio.ByteBuffer;
@@ -29,6 +28,7 @@ import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.cql3.ColumnIdentifier;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.rows.*;
+import org.apache.cassandra.io.util.DataInputPlus;
 import org.apache.cassandra.io.util.DataOutputPlus;
 import org.apache.cassandra.net.MessagingService;
 import org.apache.cassandra.utils.MergeIterator;
@@ -435,7 +435,7 @@ public abstract class UnfilteredPartitionIterators
             out.writeBoolean(false);
         }
 
-        public UnfilteredPartitionIterator deserialize(final DataInput in, final int version,
final SerializationHelper.Flag flag) throws IOException
+        public UnfilteredPartitionIterator deserialize(final DataInputPlus in, final int
version, final SerializationHelper.Flag flag) throws IOException
         {
             if (version < MessagingService.VERSION_30)
                 throw new UnsupportedOperationException();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6249a3b1/src/java/org/apache/cassandra/db/rows/UnfilteredRowIteratorSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/rows/UnfilteredRowIteratorSerializer.java b/src/java/org/apache/cassandra/db/rows/UnfilteredRowIteratorSerializer.java
index a4cfda7..8abd228 100644
--- a/src/java/org/apache/cassandra/db/rows/UnfilteredRowIteratorSerializer.java
+++ b/src/java/org/apache/cassandra/db/rows/UnfilteredRowIteratorSerializer.java
@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.db.*;
+import org.apache.cassandra.io.util.DataInputPlus;
 import org.apache.cassandra.io.util.DataOutputPlus;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.ByteBufferUtil;
@@ -174,7 +175,7 @@ public class UnfilteredRowIteratorSerializer
         return size;
     }
 
-    public Header deserializeHeader(DataInput in, int version, SerializationHelper.Flag flag)
throws IOException
+    public Header deserializeHeader(DataInputPlus in, int version, SerializationHelper.Flag
flag) throws IOException
     {
         CFMetaData metadata = CFMetaData.serializer.deserialize(in, version);
         DecoratedKey key = StorageService.getPartitioner().decorateKey(ByteBufferUtil.readWithLength(in));
@@ -207,7 +208,7 @@ public class UnfilteredRowIteratorSerializer
         while (UnfilteredSerializer.serializer.deserialize(in, header, helper, rowWriter,
markerWriter) != null);
     }
 
-    public UnfilteredRowIterator deserialize(final DataInput in, int version, SerializationHelper.Flag
flag) throws IOException
+    public UnfilteredRowIterator deserialize(final DataInputPlus in, int version, SerializationHelper.Flag
flag) throws IOException
     {
         final Header h = deserializeHeader(in, version, flag);
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6249a3b1/src/java/org/apache/cassandra/utils/UUIDSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/UUIDSerializer.java b/src/java/org/apache/cassandra/utils/UUIDSerializer.java
index 2b174fe..47b6f8c 100644
--- a/src/java/org/apache/cassandra/utils/UUIDSerializer.java
+++ b/src/java/org/apache/cassandra/utils/UUIDSerializer.java
@@ -44,4 +44,4 @@ public class UUIDSerializer implements IVersionedSerializer<UUID>
     {
         return TypeSizes.sizeof(uuid.getMostSignificantBits()) + TypeSizes.sizeof(uuid.getLeastSignificantBits());
     }
-}
\ No newline at end of file
+}


Mime
View raw message