diff --git a/CHANGES.txt b/CHANGES.txt index 1f33e6ca6b..182847660b 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) diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java index 6c53699f38..3b43960283 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); } } diff --git a/src/java/org/apache/cassandra/db/ReadResponse.java b/src/java/org/apache/cassandra/db/ReadResponse.java index 6a614167fa..3737a38315 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) diff --git a/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java b/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java index 8b2ef03575..0d3d364d65 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(); diff --git a/src/java/org/apache/cassandra/db/rows/UnfilteredRowIteratorSerializer.java b/src/java/org/apache/cassandra/db/rows/UnfilteredRowIteratorSerializer.java index a4cfda7203..8abd228ea8 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); diff --git a/src/java/org/apache/cassandra/utils/UUIDSerializer.java b/src/java/org/apache/cassandra/utils/UUIDSerializer.java index 2b174fe157..47b6f8c565 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 { return TypeSizes.sizeof(uuid.getMostSignificantBits()) + TypeSizes.sizeof(uuid.getLeastSignificantBits()); } -} \ No newline at end of file +}