cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [1/7] git commit: avoid no-op caching of byte[] on commitlog append patch by jbellis; reviewed by yukim for CASSANDRA-5199
Date Tue, 05 Feb 2013 14:46:05 GMT
avoid no-op caching of byte[] on commitlog append
patch by jbellis; reviewed by yukim for CASSANDRA-5199


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

Branch: refs/heads/cassandra-1.2
Commit: 1c79426ab86a1d26e7214d8d86b8eb24d67c0ab0
Parents: 75d0f7a
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Tue Feb 5 15:40:45 2013 +0100
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Tue Feb 5 15:40:45 2013 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 src/java/org/apache/cassandra/db/RowMutation.java  |   36 +--------------
 .../cassandra/db/commitlog/CommitLogSegment.java   |    3 +-
 3 files changed, 4 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/1c79426a/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e0e8079..5e661ae 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.2.2
+ * avoid no-op caching of byte[] on commitlog append (CASSANDRA-5199)
  * more robust solution to incomplete compactions + counters (CASSANDRA-5151)
  * fix symlinks under data dir not working (CASSANDRA-5185)
  * fix bug in compact storage metadata handling (CASSANDRA-5189)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1c79426a/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 a8e845d..5064c65 100644
--- a/src/java/org/apache/cassandra/db/RowMutation.java
+++ b/src/java/org/apache/cassandra/db/RowMutation.java
@@ -18,7 +18,6 @@
 package org.apache.cassandra.db;
 
 import java.io.DataInput;
-import java.io.DataInputStream;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.nio.ByteBuffer;
@@ -33,7 +32,6 @@ import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.marshal.UUIDType;
 import org.apache.cassandra.io.IColumnSerializer;
 import org.apache.cassandra.io.IVersionedSerializer;
-import org.apache.cassandra.io.util.FastByteArrayInputStream;
 import org.apache.cassandra.net.MessageOut;
 import org.apache.cassandra.net.MessagingService;
 import org.apache.cassandra.thrift.ColumnOrSuperColumn;
@@ -53,8 +51,6 @@ public class RowMutation implements IMutation
     // map of column family id to mutations for that column family.
     protected Map<UUID, ColumnFamily> modifications = new HashMap<UUID, ColumnFamily>();
 
-    private final Map<Integer, byte[]> preserializedBuffers = new HashMap<Integer,
byte[]>();
-
     public RowMutation(String table, ByteBuffer key)
     {
         this(table, key, new HashMap<UUID, ColumnFamily>());
@@ -116,7 +112,7 @@ public class RowMutation implements IMutation
 
         // serialize the hint with id and version as a composite column name
         QueryPath path = new QueryPath(SystemTable.HINTS_CF, null, HintedHandOffManager.comparator.decompose(hintId,
MessagingService.current_version));
-        rm.add(path, ByteBuffer.wrap(mutation.getSerializedBuffer(MessagingService.current_version)),
System.currentTimeMillis(), ttl);
+        rm.add(path, ByteBuffer.wrap(FBUtilities.serialize(mutation, serializer, MessagingService.current_version)),
System.currentTimeMillis(), ttl);
 
         return rm;
     }
@@ -277,17 +273,6 @@ public class RowMutation implements IMutation
         return new MessageOut<RowMutation>(verb, this, serializer);
     }
 
-    public synchronized byte[] getSerializedBuffer(int version) throws IOException
-    {
-        byte[] bytes = preserializedBuffers.get(version);
-        if (bytes == null)
-        {
-            bytes = FBUtilities.serialize(this, serializer, version);
-            preserializedBuffers.put(version, bytes);
-        }
-        return bytes;
-    }
-
     public String toString()
     {
         return toString(false);
@@ -358,25 +343,6 @@ public class RowMutation implements IMutation
         }
     }
 
-    public static RowMutation fromBytes(byte[] raw, int version) throws IOException
-    {
-        RowMutation rm = serializer.deserialize(new DataInputStream(new FastByteArrayInputStream(raw)),
version);
-        boolean hasCounters = false;
-        for (Map.Entry<UUID, ColumnFamily> entry : rm.modifications.entrySet())
-        {
-            if (entry.getValue().metadata().getDefaultValidator().isCommutative())
-            {
-                hasCounters = true;
-                break;
-            }
-        }
-
-        // We need to deserialize at least once for counters to cleanup the delta
-        if (!hasCounters && version == MessagingService.current_version)
-            rm.preserializedBuffers.put(version, raw);
-        return rm;
-    }
-
     public static class RowMutationSerializer implements IVersionedSerializer<RowMutation>
     {
         public void serialize(RowMutation rm, DataOutput dos, int version) throws IOException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1c79426a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
index d292aef..469ab99 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
@@ -40,6 +40,7 @@ import org.apache.cassandra.db.RowMutation;
 import org.apache.cassandra.io.FSWriteError;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.net.MessagingService;
+import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.PureJavaCrc32;
 
 /*
@@ -213,7 +214,7 @@ public class CommitLogSegment
         markDirty(rowMutation, repPos);
 
         Checksum checksum = new PureJavaCrc32();
-        byte[] serializedRow = rowMutation.getSerializedBuffer(MessagingService.current_version);
+        byte[] serializedRow = FBUtilities.serialize(rowMutation, RowMutation.serializer,
MessagingService.current_version);
 
         checksum.update(serializedRow.length);
         buffer.putInt(serializedRow.length);


Mime
View raw message