cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1128347 - in /cassandra/branches/cassandra-0.7: CHANGES.txt src/java/org/apache/cassandra/db/Column.java src/java/org/apache/cassandra/db/SuperColumn.java
Date Fri, 27 May 2011 15:07:07 GMT
Author: jbellis
Date: Fri May 27 15:07:07 2011
New Revision: 1128347

URL: http://svn.apache.org/viewvc?rev=1128347&view=rev
Log:
optimize column serializer creation
patch by jbellis; reviewed by slebresne for CASSANDRA-2716

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Column.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SuperColumn.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1128347&r1=1128346&r2=1128347&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Fri May 27 15:07:07 2011
@@ -11,6 +11,7 @@
  * clone super columns to avoid modifying them during flush (CASSANDRA-2675)
  * close scrub file handles (CASSANDRA-2669)
  * throttle migration replay (CASSANDRA-2714)
+ * optimize column serializer creation (CASSANDRA-2716)
 
 
 0.7.6

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Column.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Column.java?rev=1128347&r1=1128346&r2=1128347&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Column.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Column.java Fri May
27 15:07:07 2011
@@ -42,10 +42,11 @@ import org.apache.cassandra.utils.ByteBu
 public class Column implements IColumn
 {
     private static Logger logger = LoggerFactory.getLogger(Column.class);
+    private static ColumnSerializer serializer = new ColumnSerializer();
 
     public static ColumnSerializer serializer()
     {
-        return new ColumnSerializer();
+        return serializer;
     }
 
     protected final ByteBuffer name;

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SuperColumn.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SuperColumn.java?rev=1128347&r1=1128346&r2=1128347&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SuperColumn.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/SuperColumn.java Fri
May 27 15:07:07 2011
@@ -24,6 +24,8 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.security.MessageDigest;
 import java.util.Collection;
+import java.util.Comparator;
+import java.util.IdentityHashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentSkipListMap;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -40,15 +42,23 @@ import org.apache.cassandra.io.util.Colu
 import org.apache.cassandra.io.util.DataOutputBuffer;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
+import org.cliffc.high_scale_lib.NonBlockingHashMap;
 
 
 public class SuperColumn implements IColumn, IColumnContainer
 {
     private static Logger logger_ = LoggerFactory.getLogger(SuperColumn.class);
 
+    private static NonBlockingHashMap<Comparator, SuperColumnSerializer> serializers
= new NonBlockingHashMap<Comparator, SuperColumnSerializer>();
     public static SuperColumnSerializer serializer(AbstractType comparator)
     {
-        return new SuperColumnSerializer(comparator);
+        SuperColumnSerializer serializer = serializers.get(comparator);
+        if (serializer == null)
+        {
+            serializer = new SuperColumnSerializer(comparator);
+            serializers.put(comparator, serializer);
+        }
+        return serializer;
     }
 
     private ByteBuffer name_;



Mime
View raw message