Repository: cassandra Updated Branches: refs/heads/trunk 376e552c4 -> 43c3ab445
Simplify/optimise CFMetaData serialization patch by benedict; reviewed by sylvain for CASSANDRA-9709 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/43c3ab44 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/43c3ab44 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/43c3ab44 Branch: refs/heads/trunk Commit: 43c3ab44573dee5fd099895146f4a008b54901f6 Parents: 376e552 Author: Benedict Elliott Smith <bened...@apache.org> Authored: Wed Jul 15 18:50:04 2015 +0100 Committer: Benedict Elliott Smith <bened...@apache.org> Committed: Wed Jul 15 18:50:04 2015 +0100 ---------------------------------------------------------------------- .../org/apache/cassandra/config/CFMetaData.java | 21 ++++---------------- 1 file changed, 4 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/43c3ab44/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 1219952..84639dc 100644 --- a/src/java/org/apache/cassandra/config/CFMetaData.java +++ b/src/java/org/apache/cassandra/config/CFMetaData.java @@ -1516,29 +1516,16 @@ public final class CFMetaData // we could make UUIDSerializer work as the serializer below, but I'll keep that to later. public static class Serializer { - private static void writeLongAsSeparateBytes(long value, DataOutputPlus out) throws IOException - { - for (int i = 7; i >= 0; i--) - out.writeByte((int)((value >> (8 * i)) & 0xFF)); - } - - private static long readLongAsSeparateBytes(DataInput in) throws IOException - { - long val = 0; - for (int i = 7; i >= 0; i--) - val |= ((long)in.readUnsignedByte()) << (8 * i); - return val; - } - public void serialize(CFMetaData metadata, DataOutputPlus out, int version) throws IOException { - writeLongAsSeparateBytes(metadata.cfId.getMostSignificantBits(), out); - writeLongAsSeparateBytes(metadata.cfId.getLeastSignificantBits(), out); + // 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())); } public CFMetaData deserialize(DataInput in, int version) throws IOException { - UUID cfId = new UUID(readLongAsSeparateBytes(in), readLongAsSeparateBytes(in)); + UUID cfId = new UUID(Long.reverseBytes(in.readLong()), Long.reverseBytes(in.readLong())); CFMetaData metadata = Schema.instance.getCFMetaData(cfId); if (metadata == null) {