cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [2/2] git commit: Cleanup AbstractType/TypeSerializer classes
Date Fri, 12 Jul 2013 13:29:18 GMT
Cleanup AbstractType/TypeSerializer classes

patch by slebresne; reviewed by carlyeks for CASSANDRA-5744


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

Branch: refs/heads/trunk
Commit: daff1fce0f17c03d51e06d1d9a27a70d9785a5a6
Parents: 829688f
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Fri Jul 12 15:25:48 2013 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Fri Jul 12 15:25:48 2013 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |   9 ++-
 src/java/org/apache/cassandra/cql3/Lists.java   |   2 +-
 src/java/org/apache/cassandra/cql3/Maps.java    |   2 +-
 src/java/org/apache/cassandra/cql3/Sets.java    |   2 +-
 .../db/marshal/AbstractCommutativeType.java     |   2 +
 .../db/marshal/AbstractCompositeType.java       |  12 +---
 .../cassandra/db/marshal/AbstractType.java      |  24 +++++--
 .../apache/cassandra/db/marshal/AsciiType.java  |  20 ------
 .../cassandra/db/marshal/BooleanType.java       |  66 +++++++------------
 .../apache/cassandra/db/marshal/BytesType.java  |  21 ------
 .../db/marshal/ColumnToCollectionType.java      |  11 +---
 .../cassandra/db/marshal/CounterColumnType.java |   6 --
 .../apache/cassandra/db/marshal/DateType.java   |  20 ------
 .../cassandra/db/marshal/DecimalType.java       |  25 -------
 .../apache/cassandra/db/marshal/DoubleType.java |  21 ------
 .../db/marshal/DynamicCompositeType.java        |   4 +-
 .../apache/cassandra/db/marshal/EmptyType.java  |  15 -----
 .../apache/cassandra/db/marshal/FloatType.java  |  21 ------
 .../cassandra/db/marshal/InetAddressType.java   |  21 ------
 .../apache/cassandra/db/marshal/Int32Type.java  |  21 ------
 .../cassandra/db/marshal/IntegerType.java       |  21 ------
 .../cassandra/db/marshal/LexicalUUIDType.java   |  21 ------
 .../apache/cassandra/db/marshal/ListType.java   |  23 +------
 .../db/marshal/LocalByPartionerType.java        |   3 +
 .../apache/cassandra/db/marshal/LongType.java   |  21 ------
 .../apache/cassandra/db/marshal/MapType.java    |  63 ++----------------
 .../cassandra/db/marshal/ReversedType.java      |  16 -----
 .../apache/cassandra/db/marshal/SetType.java    |  16 +----
 .../cassandra/db/marshal/TimeUUIDType.java      |  22 -------
 .../cassandra/db/marshal/TimestampType.java     |  20 ------
 .../apache/cassandra/db/marshal/UTF8Type.java   |  21 ------
 .../apache/cassandra/db/marshal/UUIDType.java   |  22 -------
 .../serializers/AbstractTextSerializer.java     |  17 ++---
 .../serializers/BooleanSerializer.java          |  22 ++-----
 .../cassandra/serializers/BytesSerializer.java  |   7 +-
 .../serializers/CollectionSerializer.java       |   6 --
 .../serializers/DecimalSerializer.java          |  19 ++----
 .../cassandra/serializers/DoubleSerializer.java |  20 ++----
 .../cassandra/serializers/EmptySerializer.java  |   9 +--
 .../cassandra/serializers/FloatSerializer.java  |  21 ++----
 .../serializers/InetAddressSerializer.java      |  17 ++---
 .../cassandra/serializers/Int32Serializer.java  |  20 +-----
 .../serializers/IntegerSerializer.java          |  14 +---
 .../cassandra/serializers/ListSerializer.java   |   8 +--
 .../cassandra/serializers/LongSerializer.java   |  22 ++-----
 .../cassandra/serializers/MapSerializer.java    |  19 ++++--
 .../cassandra/serializers/SetSerializer.java    |   8 +--
 .../serializers/TimestampSerializer.java        |  27 ++------
 .../cassandra/serializers/TypeSerializer.java   |  11 ++--
 .../cassandra/serializers/UUIDSerializer.java   |  27 ++------
 .../org/apache/cassandra/tools/Shuffle.java     |   2 +-
 .../cassandra/utils/BooleanSerializer.java      |   2 +-
 test/data/serialization/2.0/db.RowMutation.bin  | Bin 3599 -> 3599 bytes
 .../cassandra/cql/jdbc/JdbcDecimalTest.java     |   4 +-
 .../cassandra/db/marshal/RoundTripTest.java     |   6 --
 .../cassandra/serializers/ClientUtilsTest.java  |  37 ++++-------
 56 files changed, 175 insertions(+), 764 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index db74bec..ee62cac 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,9 @@
-2.0
+2.0.0-beta2
+ * Allow nodetool with no args, and with help to run without a server (CASSANDRA-5734)
+ * Cleanup AbstractType/TypeSerializer classes (CASSANDRA-5744)
+
+
+2.0.0-beta1
  * Removed on-heap row cache (CASSANDRA-5348)
  * use nanotime consistently for node-local timeouts (CASSANDRA-5581)
  * Avoid unnecessary second pass on name-based queries (CASSANDRA-5577)
@@ -73,7 +78,7 @@
  * Auto paging in binary protocol (CASSANDRA-4415, 5714)
  * Don't tie client side use of AbstractType to JDBC (CASSANDRA-4495)
  * Adds new TimestampType to replace DateType (CASSANDRA-5723, CASSANDRA-5729)
- * Allow nodetool with no args, and with help to run without a server (CASSANDRA-5734)
+
 
 1.2.7
  * Add timeout events to query traces (CASSANDRA-5520)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/cql3/Lists.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Lists.java b/src/java/org/apache/cassandra/cql3/Lists.java
index e2a4945..8906afb 100644
--- a/src/java/org/apache/cassandra/cql3/Lists.java
+++ b/src/java/org/apache/cassandra/cql3/Lists.java
@@ -138,7 +138,7 @@ public abstract class Lists
             {
                 // Collections have this small hack that validate cannot be called on a serialized object,
                 // but compose does the validation (so we're fine).
-                List<?> l = type.compose(value);
+                List<?> l = (List<?>)type.compose(value);
                 List<ByteBuffer> elements = new ArrayList<ByteBuffer>(l.size());
                 for (Object element : l)
                     elements.add(type.elements.decompose(element));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/cql3/Maps.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Maps.java b/src/java/org/apache/cassandra/cql3/Maps.java
index 4486dca..108cb64 100644
--- a/src/java/org/apache/cassandra/cql3/Maps.java
+++ b/src/java/org/apache/cassandra/cql3/Maps.java
@@ -155,7 +155,7 @@ public abstract class Maps
             {
                 // Collections have this small hack that validate cannot be called on a serialized object,
                 // but compose does the validation (so we're fine).
-                Map<?, ?> m = type.compose(value);
+                Map<?, ?> m = (Map<?, ?>)type.compose(value);
                 Map<ByteBuffer, ByteBuffer> map = new LinkedHashMap<ByteBuffer, ByteBuffer>(m.size());
                 for (Map.Entry<?, ?> entry : m.entrySet())
                     map.put(type.keys.decompose(entry.getKey()), type.values.decompose(entry.getValue()));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/cql3/Sets.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Sets.java b/src/java/org/apache/cassandra/cql3/Sets.java
index 3c50db2..9007cec 100644
--- a/src/java/org/apache/cassandra/cql3/Sets.java
+++ b/src/java/org/apache/cassandra/cql3/Sets.java
@@ -148,7 +148,7 @@ public abstract class Sets
             {
                 // Collections have this small hack that validate cannot be called on a serialized object,
                 // but compose does the validation (so we're fine).
-                Set<?> s = type.compose(value);
+                Set<?> s = (Set<?>)type.compose(value);
                 Set<ByteBuffer> elements = new LinkedHashSet<ByteBuffer>(s.size());
                 for (Object element : s)
                     elements.add(type.elements.decompose(element));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/AbstractCommutativeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/AbstractCommutativeType.java b/src/java/org/apache/cassandra/db/marshal/AbstractCommutativeType.java
index a9c151d..01db148 100644
--- a/src/java/org/apache/cassandra/db/marshal/AbstractCommutativeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractCommutativeType.java
@@ -29,11 +29,13 @@ public abstract class AbstractCommutativeType extends AbstractType<Long>
         return true;
     }
 
+    @Override
     public Long compose(ByteBuffer bytes)
     {
         return CounterContext.instance().total(bytes);
     }
 
+    @Override
     public ByteBuffer decompose(Long value)
     {
         return ByteBufferUtil.bytes(value);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
index 0626ef5..d002aa7 100644
--- a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
@@ -286,6 +286,7 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
         return bb;
     }
 
+    @Override
     public void validate(ByteBuffer bytes) throws MarshalException
     {
         ByteBuffer bb = bytes.duplicate();
@@ -319,17 +320,6 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
 
     public abstract ByteBuffer decompose(Object... objects);
 
-    public ByteBuffer compose(ByteBuffer bytes)
-    {
-        return bytes;
-    }
-
-    public ByteBuffer decompose(ByteBuffer value)
-    {
-        return value;
-    }
-
-    @Override
     public TypeSerializer<ByteBuffer> getSerializer()
     {
         return BytesSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/AbstractType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/AbstractType.java b/src/java/org/apache/cassandra/db/marshal/AbstractType.java
index 82068f3..74fe446 100644
--- a/src/java/org/apache/cassandra/db/marshal/AbstractType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractType.java
@@ -137,12 +137,25 @@ public abstract class AbstractType<T> implements Comparator<ByteBuffer>
         };
     }
 
-    public abstract T compose(ByteBuffer bytes);
+    public T compose(ByteBuffer bytes)
+    {
+        return getSerializer().deserialize(bytes);
+    }
 
-    public abstract ByteBuffer decompose(T value);
+    public ByteBuffer decompose(T value)
+    {
+        return getSerializer().serialize(value);
+    }
 
     /** get a string representation of the bytes suitable for log messages */
-    public abstract String getString(ByteBuffer bytes);
+    public String getString(ByteBuffer bytes)
+    {
+        TypeSerializer<T> serializer = getSerializer();
+        serializer.validate(bytes);
+
+        T value = serializer.deserialize(bytes);
+        return value == null ? "null" : serializer.toString(value);
+    }
 
     /** get a byte representation of the given string. */
     public abstract ByteBuffer fromString(String source) throws MarshalException;
@@ -154,7 +167,10 @@ public abstract class AbstractType<T> implements Comparator<ByteBuffer>
     }
 
     /* validate that the byte array is a valid sequence for the type we are supposed to be comparing */
-    public abstract void validate(ByteBuffer bytes) throws MarshalException;
+    public void validate(ByteBuffer bytes) throws MarshalException
+    {
+        getSerializer().validate(bytes);
+    }
 
     /* Most of our internal type should override that. */
     public CQL3Type asCQL3Type()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/AsciiType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/AsciiType.java b/src/java/org/apache/cassandra/db/marshal/AsciiType.java
index fb96aff..5142f37 100644
--- a/src/java/org/apache/cassandra/db/marshal/AsciiType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AsciiType.java
@@ -30,36 +30,16 @@ public class AsciiType extends AbstractType<String>
 
     AsciiType() {} // singleton
 
-    public String getString(ByteBuffer bytes)
-    {
-        return AsciiSerializer.instance.getString(bytes);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         return BytesType.bytesCompare(o1, o2);
     }
 
-    public String compose(ByteBuffer bytes)
-    {
-        return AsciiSerializer.instance.getString(bytes);
-    }
-
-    public ByteBuffer decompose(String value)
-    {
-        return AsciiSerializer.instance.deserialize(value);
-    }
-
     public ByteBuffer fromString(String source)
     {
         return decompose(source);
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        AsciiSerializer.instance.validate(bytes);
-    }
-
     public CQL3Type asCQL3Type()
     {
         return CQL3Type.Native.ASCII;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/BooleanType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/BooleanType.java b/src/java/org/apache/cassandra/db/marshal/BooleanType.java
index 95c6de0..3a9fdfa 100644
--- a/src/java/org/apache/cassandra/db/marshal/BooleanType.java
+++ b/src/java/org/apache/cassandra/db/marshal/BooleanType.java
@@ -26,59 +26,37 @@ import org.apache.cassandra.serializers.MarshalException;
 
 public class BooleanType extends AbstractType<Boolean>
 {
-  public static final BooleanType instance = new BooleanType();
+    public static final BooleanType instance = new BooleanType();
 
-  BooleanType() {} // singleton
+    BooleanType() {} // singleton
 
-  public Boolean compose(ByteBuffer bytes)
-  {
-      return BooleanSerializer.instance.serialize(bytes);
-  }
-
-  public ByteBuffer decompose(Boolean value)
-  {
-      return BooleanSerializer.instance.deserialize(value);
-  }
-
-  public int compare(ByteBuffer o1, ByteBuffer o2)
-  {
-      if ((o1 == null) || (o1.remaining() != 1))
-        return ((o2 == null) || (o2.remaining() != 1)) ? 0 : -1;
-      if ((o2 == null) || (o2.remaining() != 1))
-        return 1;
-
-      return o1.compareTo(o2);
-  }
-
-  public String getString(ByteBuffer bytes)
-  {
-      return BooleanSerializer.instance.getString(bytes);
-  }
-
-  public ByteBuffer fromString(String source) throws MarshalException
-  {
+    public int compare(ByteBuffer o1, ByteBuffer o2)
+    {
+        if ((o1 == null) || (o1.remaining() != 1))
+            return ((o2 == null) || (o2.remaining() != 1)) ? 0 : -1;
+        if ((o2 == null) || (o2.remaining() != 1))
+            return 1;
 
-      if (source.isEmpty()|| source.equalsIgnoreCase(Boolean.FALSE.toString()))
-          return decompose(false);
+        return o1.compareTo(o2);
+    }
 
-      if (source.equalsIgnoreCase(Boolean.TRUE.toString()))
-          return decompose(true);
+    public ByteBuffer fromString(String source) throws MarshalException
+    {
 
-      throw new MarshalException(String.format("unable to make boolean from '%s'", source));
+        if (source.isEmpty()|| source.equalsIgnoreCase(Boolean.FALSE.toString()))
+            return decompose(false);
 
- }
+        if (source.equalsIgnoreCase(Boolean.TRUE.toString()))
+            return decompose(true);
 
-  public void validate(ByteBuffer bytes) throws MarshalException
-  {
-      BooleanSerializer.instance.validate(bytes);
-  }
+        throw new MarshalException(String.format("unable to make boolean from '%s'", source));
+    }
 
-  public CQL3Type asCQL3Type()
-  {
-      return CQL3Type.Native.BOOLEAN;
-  }
+    public CQL3Type asCQL3Type()
+    {
+        return CQL3Type.Native.BOOLEAN;
+    }
 
-    @Override
     public TypeSerializer<Boolean> getSerializer()
     {
         return BooleanSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/BytesType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/BytesType.java b/src/java/org/apache/cassandra/db/marshal/BytesType.java
index 6601af3..4aa1ff4 100644
--- a/src/java/org/apache/cassandra/db/marshal/BytesType.java
+++ b/src/java/org/apache/cassandra/db/marshal/BytesType.java
@@ -32,16 +32,6 @@ public class BytesType extends AbstractType<ByteBuffer>
 
     BytesType() {} // singleton
 
-    public ByteBuffer compose(ByteBuffer bytes)
-    {
-        return BytesSerializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(ByteBuffer value)
-    {
-        return BytesSerializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         return BytesType.bytesCompare(o1, o2);
@@ -55,11 +45,6 @@ public class BytesType extends AbstractType<ByteBuffer>
         return ByteBufferUtil.compareUnsigned(o1, o2);
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return BytesSerializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source)
     {
         try
@@ -72,11 +57,6 @@ public class BytesType extends AbstractType<ByteBuffer>
         }
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        BytesSerializer.instance.validate(bytes);
-    }
-
     @Override
     public boolean isCompatibleWith(AbstractType<?> previous)
     {
@@ -90,7 +70,6 @@ public class BytesType extends AbstractType<ByteBuffer>
         return CQL3Type.Native.BLOB;
     }
 
-    @Override
     public TypeSerializer<ByteBuffer> getSerializer()
     {
         return BytesSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/ColumnToCollectionType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/ColumnToCollectionType.java b/src/java/org/apache/cassandra/db/marshal/ColumnToCollectionType.java
index 7dda157..a4f7857 100644
--- a/src/java/org/apache/cassandra/db/marshal/ColumnToCollectionType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ColumnToCollectionType.java
@@ -74,16 +74,6 @@ public class ColumnToCollectionType extends AbstractType<ByteBuffer>
         return t.nameComparator().compare(o1, o2);
     }
 
-    public ByteBuffer compose(ByteBuffer bytes)
-    {
-        return BytesType.instance.compose(bytes);
-    }
-
-    public ByteBuffer decompose(ByteBuffer value)
-    {
-        return BytesType.instance.decompose(value);
-    }
-
     public String getString(ByteBuffer bytes)
     {
         return BytesType.instance.getString(bytes);
@@ -101,6 +91,7 @@ public class ColumnToCollectionType extends AbstractType<ByteBuffer>
         }
     }
 
+    @Override
     public void validate(ByteBuffer bytes)
     {
         throw new UnsupportedOperationException("ColumnToCollectionType should only be used in composite types, never alone");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/CounterColumnType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/CounterColumnType.java b/src/java/org/apache/cassandra/db/marshal/CounterColumnType.java
index ef1ffc6..ba7c59c 100644
--- a/src/java/org/apache/cassandra/db/marshal/CounterColumnType.java
+++ b/src/java/org/apache/cassandra/db/marshal/CounterColumnType.java
@@ -58,12 +58,6 @@ public class CounterColumnType extends AbstractCommutativeType
         return ByteBufferUtil.hexToBytes(source);
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        if (bytes.remaining() != 8 && bytes.remaining() != 0)
-            throw new MarshalException(String.format("Expected 8 or 0 byte long (%d)", bytes.remaining()));
-    }
-
     public CQL3Type asCQL3Type()
     {
         return CQL3Type.Native.COUNTER;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/DateType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/DateType.java b/src/java/org/apache/cassandra/db/marshal/DateType.java
index f97067a..dda17e8 100644
--- a/src/java/org/apache/cassandra/db/marshal/DateType.java
+++ b/src/java/org/apache/cassandra/db/marshal/DateType.java
@@ -42,16 +42,6 @@ public class DateType extends AbstractType<Date>
 
     DateType() {} // singleton
 
-    public Date compose(ByteBuffer bytes)
-    {
-        return TimestampSerializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(Date value)
-    {
-        return TimestampSerializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         if (o1.remaining() == 0)
@@ -66,11 +56,6 @@ public class DateType extends AbstractType<Date>
         return ByteBufferUtil.compareUnsigned(o1, o2);
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return TimestampSerializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source) throws MarshalException
     {
       // Return an empty ByteBuffer for an empty string.
@@ -134,11 +119,6 @@ public class DateType extends AbstractType<Date>
         return false;
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        TimestampSerializer.instance.validate(bytes);
-    }
-
     public TypeSerializer<Date> getSerializer()
     {
         return TimestampSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/DecimalType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/DecimalType.java b/src/java/org/apache/cassandra/db/marshal/DecimalType.java
index 230df51..2ac8480 100644
--- a/src/java/org/apache/cassandra/db/marshal/DecimalType.java
+++ b/src/java/org/apache/cassandra/db/marshal/DecimalType.java
@@ -46,25 +46,6 @@ public class DecimalType extends AbstractType<BigDecimal>
         return compose(bb0).compareTo(compose(bb1));
     }
 
-    public BigDecimal compose(ByteBuffer bytes)
-    {
-        return DecimalSerializer.instance.serialize(bytes);
-    }
-
-    /**
-     * The bytes of the ByteBuffer are made up of 4 bytes of int containing the scale
-     * followed by the n bytes it takes to store a BigInteger.
-     */
-    public ByteBuffer decompose(BigDecimal value)
-    {
-        return DecimalSerializer.instance.deserialize(value);
-    }
-
-    public String getString(ByteBuffer bytes)
-    {
-        return DecimalSerializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source) throws MarshalException
     {
         // Return an empty ByteBuffer for an empty string.
@@ -84,17 +65,11 @@ public class DecimalType extends AbstractType<BigDecimal>
         return decompose(decimal);
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        DecimalSerializer.instance.validate(bytes);
-    }
-
     public CQL3Type asCQL3Type()
     {
         return CQL3Type.Native.DECIMAL;
     }
 
-    @Override
     public TypeSerializer<BigDecimal> getSerializer()
     {
         return DecimalSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/DoubleType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/DoubleType.java b/src/java/org/apache/cassandra/db/marshal/DoubleType.java
index 4ff4db6..35b33d6 100644
--- a/src/java/org/apache/cassandra/db/marshal/DoubleType.java
+++ b/src/java/org/apache/cassandra/db/marshal/DoubleType.java
@@ -31,16 +31,6 @@ public class DoubleType extends AbstractType<Double>
 
     DoubleType() {} // singleton
 
-    public Double compose(ByteBuffer bytes)
-    {
-        return DoubleSerializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(Double value)
-    {
-        return DoubleSerializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         if (o1.remaining() == 0)
@@ -55,11 +45,6 @@ public class DoubleType extends AbstractType<Double>
         return compose(o1).compareTo(compose(o2));
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return DoubleSerializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source) throws MarshalException
     {
       // Return an empty ByteBuffer for an empty string.
@@ -79,17 +64,11 @@ public class DoubleType extends AbstractType<Double>
       return decompose(d);
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        DoubleSerializer.instance.validate(bytes);
-    }
-
     public CQL3Type asCQL3Type()
     {
         return CQL3Type.Native.DOUBLE;
     }
 
-    @Override
     public TypeSerializer<Double> getSerializer()
     {
         return DoubleSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java b/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
index b68505e..35e6e33 100644
--- a/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
@@ -336,11 +336,13 @@ public class DynamicCompositeType extends AbstractCompositeType
             return cmp;
         }
 
+        @Override
         public Void compose(ByteBuffer bytes)
         {
             throw new UnsupportedOperationException();
         }
 
+        @Override
         public ByteBuffer decompose(Void value)
         {
             throw new UnsupportedOperationException();
@@ -356,12 +358,12 @@ public class DynamicCompositeType extends AbstractCompositeType
             throw new UnsupportedOperationException();
         }
 
+        @Override
         public void validate(ByteBuffer bytes)
         {
             throw new UnsupportedOperationException();
         }
 
-        @Override
         public TypeSerializer<Void> getSerializer()
         {
             throw new UnsupportedOperationException();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/EmptyType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/EmptyType.java b/src/java/org/apache/cassandra/db/marshal/EmptyType.java
index 74cf3fe..0ddb9ea 100644
--- a/src/java/org/apache/cassandra/db/marshal/EmptyType.java
+++ b/src/java/org/apache/cassandra/db/marshal/EmptyType.java
@@ -34,16 +34,6 @@ public class EmptyType extends AbstractType<Void>
 
     private EmptyType() {} // singleton
 
-    public Void compose(ByteBuffer bytes)
-    {
-        return null;
-    }
-
-    public ByteBuffer decompose(Void value)
-    {
-        return ByteBufferUtil.EMPTY_BYTE_BUFFER;
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         return 0;
@@ -62,11 +52,6 @@ public class EmptyType extends AbstractType<Void>
         return ByteBufferUtil.EMPTY_BYTE_BUFFER;
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        EmptySerializer.instance.validate(bytes);
-    }
-
     public TypeSerializer<Void> getSerializer()
     {
         return EmptySerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/FloatType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/FloatType.java b/src/java/org/apache/cassandra/db/marshal/FloatType.java
index 6b9782e..bee226e 100644
--- a/src/java/org/apache/cassandra/db/marshal/FloatType.java
+++ b/src/java/org/apache/cassandra/db/marshal/FloatType.java
@@ -32,16 +32,6 @@ public class FloatType extends AbstractType<Float>
 
     FloatType() {} // singleton
 
-    public Float compose(ByteBuffer bytes)
-    {
-        return FloatSerializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(Float value)
-    {
-        return FloatSerializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         if (o1.remaining() == 0)
@@ -56,11 +46,6 @@ public class FloatType extends AbstractType<Float>
         return compose(o1).compareTo(compose(o2));
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return FloatSerializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source) throws MarshalException
     {
       // Return an empty ByteBuffer for an empty string.
@@ -78,17 +63,11 @@ public class FloatType extends AbstractType<Float>
       }
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        FloatSerializer.instance.validate(bytes);
-    }
-
     public CQL3Type asCQL3Type()
     {
         return CQL3Type.Native.FLOAT;
     }
 
-    @Override
     public TypeSerializer<Float> getSerializer()
     {
         return FloatSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/InetAddressType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/InetAddressType.java b/src/java/org/apache/cassandra/db/marshal/InetAddressType.java
index fa5ce95..c29e8ac 100644
--- a/src/java/org/apache/cassandra/db/marshal/InetAddressType.java
+++ b/src/java/org/apache/cassandra/db/marshal/InetAddressType.java
@@ -32,26 +32,11 @@ public class InetAddressType extends AbstractType<InetAddress>
 
     InetAddressType() {} // singleton
 
-    public InetAddress compose(ByteBuffer bytes)
-    {
-        return InetAddressSerializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(InetAddress value)
-    {
-        return InetAddressSerializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         return ByteBufferUtil.compareUnsigned(o1, o2);
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return InetAddressSerializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source) throws MarshalException
     {
         // Return an empty ByteBuffer for an empty string.
@@ -72,17 +57,11 @@ public class InetAddressType extends AbstractType<InetAddress>
         return decompose(address);
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        InetAddressSerializer.instance.validate(bytes);
-    }
-
     public CQL3Type asCQL3Type()
     {
         return CQL3Type.Native.INET;
     }
 
-    @Override
     public TypeSerializer<InetAddress> getSerializer()
     {
         return InetAddressSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/Int32Type.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/Int32Type.java b/src/java/org/apache/cassandra/db/marshal/Int32Type.java
index ec05cb1..2f37721 100644
--- a/src/java/org/apache/cassandra/db/marshal/Int32Type.java
+++ b/src/java/org/apache/cassandra/db/marshal/Int32Type.java
@@ -33,16 +33,6 @@ public class Int32Type extends AbstractType<Integer>
     {
     } // singleton
 
-    public Integer compose(ByteBuffer bytes)
-    {
-        return Int32Serializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(Integer value)
-    {
-        return Int32Serializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         if (o1.remaining() == 0)
@@ -62,11 +52,6 @@ public class Int32Type extends AbstractType<Integer>
         return ByteBufferUtil.compareUnsigned(o1, o2);
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return Int32Serializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source) throws MarshalException
     {
         // Return an empty ByteBuffer for an empty string.
@@ -87,17 +72,11 @@ public class Int32Type extends AbstractType<Integer>
         return decompose(int32Type);
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        Int32Serializer.instance.validate(bytes);
-    }
-
     public CQL3Type asCQL3Type()
     {
         return CQL3Type.Native.INT;
     }
 
-    @Override
     public TypeSerializer<Integer> getSerializer()
     {
         return Int32Serializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/IntegerType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/IntegerType.java b/src/java/org/apache/cassandra/db/marshal/IntegerType.java
index d602442..726769b 100644
--- a/src/java/org/apache/cassandra/db/marshal/IntegerType.java
+++ b/src/java/org/apache/cassandra/db/marshal/IntegerType.java
@@ -58,16 +58,6 @@ public final class IntegerType extends AbstractType<BigInteger>
 
     IntegerType() {/* singleton */}
 
-    public BigInteger compose(ByteBuffer bytes)
-    {
-        return IntegerSerializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(BigInteger value)
-    {
-        return IntegerSerializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer lhs, ByteBuffer rhs)
     {
         int lhsLen = lhs.remaining();
@@ -126,11 +116,6 @@ public final class IntegerType extends AbstractType<BigInteger>
         return 0;
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return IntegerSerializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source) throws MarshalException
     {
         // Return an empty ByteBuffer for an empty string.
@@ -151,17 +136,11 @@ public final class IntegerType extends AbstractType<BigInteger>
         return decompose(integerType);
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        IntegerSerializer.instance.validate(bytes);
-    }
-
     public CQL3Type asCQL3Type()
     {
         return CQL3Type.Native.VARINT;
     }
 
-    @Override
     public TypeSerializer<BigInteger> getSerializer()
     {
         return IntegerSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/LexicalUUIDType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/LexicalUUIDType.java b/src/java/org/apache/cassandra/db/marshal/LexicalUUIDType.java
index d1a6590..303169f 100644
--- a/src/java/org/apache/cassandra/db/marshal/LexicalUUIDType.java
+++ b/src/java/org/apache/cassandra/db/marshal/LexicalUUIDType.java
@@ -34,16 +34,6 @@ public class LexicalUUIDType extends AbstractType<UUID>
     {
     } // singleton
 
-    public UUID compose(ByteBuffer bytes)
-    {
-        return UUIDSerializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(UUID value)
-    {
-        return UUIDSerializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         if (o1.remaining() == 0)
@@ -58,11 +48,6 @@ public class LexicalUUIDType extends AbstractType<UUID>
         return UUIDGen.getUUID(o1).compareTo(UUIDGen.getUUID(o2));
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return UUIDSerializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source) throws MarshalException
     {
         // Return an empty ByteBuffer for an empty string.
@@ -79,12 +64,6 @@ public class LexicalUUIDType extends AbstractType<UUID>
         }
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        UUIDSerializer.instance.validate(bytes);
-    }
-
-    @Override
     public TypeSerializer<UUID> getSerializer()
     {
         return UUIDSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/ListType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/ListType.java b/src/java/org/apache/cassandra/db/marshal/ListType.java
index 93c4dae..8331897 100644
--- a/src/java/org/apache/cassandra/db/marshal/ListType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ListType.java
@@ -33,7 +33,7 @@ public class ListType<T> extends CollectionType<List<T>>
     private static final Map<AbstractType<?>, ListType> instances = new HashMap<AbstractType<?>, ListType>();
 
     public final AbstractType<T> elements;
-    public final ListSerializer<T> composer;
+    public final ListSerializer<T> serializer;
 
     public static ListType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
     {
@@ -59,7 +59,7 @@ public class ListType<T> extends CollectionType<List<T>>
     {
         super(Kind.LIST);
         this.elements = elements;
-        this.composer = ListSerializer.getInstance(elements.getSerializer());
+        this.serializer = ListSerializer.getInstance(elements.getSerializer());
     }
 
     public AbstractType<UUID> nameComparator()
@@ -72,26 +72,9 @@ public class ListType<T> extends CollectionType<List<T>>
         return elements;
     }
 
-    public List<T> compose(ByteBuffer bytes)
-    {
-        return composer.serialize(bytes);
-    }
-
-    /**
-     * Layout is: {@code <n><s_1><b_1>...<s_n><b_n> }
-     * where:
-     *   n is the number of elements
-     *   s_i is the number of bytes composing the ith element
-     *   b_i is the s_i bytes composing the ith element
-     */
-    public ByteBuffer decompose(List<T> value)
-    {
-        return composer.deserialize(value);
-    }
-
     public TypeSerializer<List<T>> getSerializer()
     {
-        return composer;
+        return serializer;
     }
 
     protected void appendToStringBuilder(StringBuilder sb)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java b/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
index 22b5214..2703489 100644
--- a/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
+++ b/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
@@ -39,11 +39,13 @@ public class LocalByPartionerType<T extends Token> extends AbstractType<ByteBuff
         this.partitioner = partitioner;
     }
 
+    @Override
     public ByteBuffer compose(ByteBuffer bytes)
     {
         throw new UnsupportedOperationException("You can't do this with a local partitioner.");
     }
 
+    @Override
     public ByteBuffer decompose(ByteBuffer bytes)
     {
         throw new UnsupportedOperationException("You can't do this with a local partitioner.");
@@ -65,6 +67,7 @@ public class LocalByPartionerType<T extends Token> extends AbstractType<ByteBuff
         return RowPosition.forKey(o1, partitioner).compareTo(RowPosition.forKey(o2, partitioner));
     }
 
+    @Override
     public void validate(ByteBuffer bytes) throws MarshalException
     {
         throw new IllegalStateException("You shouldn't be validating this.");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/LongType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/LongType.java b/src/java/org/apache/cassandra/db/marshal/LongType.java
index 262265f..142683d 100644
--- a/src/java/org/apache/cassandra/db/marshal/LongType.java
+++ b/src/java/org/apache/cassandra/db/marshal/LongType.java
@@ -31,16 +31,6 @@ public class LongType extends AbstractType<Long>
 
     LongType() {} // singleton
 
-    public Long compose(ByteBuffer bytes)
-    {
-        return LongSerializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(Long value)
-    {
-        return LongSerializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         return compareLongs(o1, o2);
@@ -64,11 +54,6 @@ public class LongType extends AbstractType<Long>
         return ByteBufferUtil.compareUnsigned(o1, o2);
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return LongSerializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source) throws MarshalException
     {
         // Return an empty ByteBuffer for an empty string.
@@ -89,17 +74,11 @@ public class LongType extends AbstractType<Long>
         return decompose(longType);
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-
-    }
-
     public CQL3Type asCQL3Type()
     {
         return CQL3Type.Native.BIGINT;
     }
 
-    @Override
     public TypeSerializer<Long> getSerializer()
     {
         return LongSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/MapType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/MapType.java b/src/java/org/apache/cassandra/db/marshal/MapType.java
index 6d20166..39cf307 100644
--- a/src/java/org/apache/cassandra/db/marshal/MapType.java
+++ b/src/java/org/apache/cassandra/db/marshal/MapType.java
@@ -36,7 +36,7 @@ public class MapType<K, V> extends CollectionType<Map<K, V>>
 
     public final AbstractType<K> keys;
     public final AbstractType<V> values;
-    private final MapSerializer<K, V> composer;
+    private final MapSerializer<K, V> serializer;
 
     public static MapType<?, ?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
     {
@@ -64,7 +64,7 @@ public class MapType<K, V> extends CollectionType<Map<K, V>>
         super(Kind.MAP);
         this.keys = keys;
         this.values = values;
-        this.composer = MapSerializer.getInstance(keys.getSerializer(), values.getSerializer());
+        this.serializer = MapSerializer.getInstance(keys.getSerializer(), values.getSerializer());
     }
 
     public AbstractType<K> nameComparator()
@@ -77,65 +77,10 @@ public class MapType<K, V> extends CollectionType<Map<K, V>>
         return values;
     }
 
-    public Map<K, V> compose(ByteBuffer bytes)
-    {
-        try
-        {
-            ByteBuffer input = bytes.duplicate();
-            int n = getUnsignedShort(input);
-            Map<K, V> m = new LinkedHashMap<K, V>(n);
-            for (int i = 0; i < n; i++)
-            {
-                int sk = getUnsignedShort(input);
-                byte[] datak = new byte[sk];
-                input.get(datak);
-                ByteBuffer kbb = ByteBuffer.wrap(datak);
-                keys.validate(kbb);
-
-                int sv = getUnsignedShort(input);
-                byte[] datav = new byte[sv];
-                input.get(datav);
-                ByteBuffer vbb = ByteBuffer.wrap(datav);
-                values.validate(vbb);
-
-                m.put(keys.compose(kbb), values.compose(vbb));
-            }
-            return m;
-        }
-        catch (BufferUnderflowException e)
-        {
-            throw new MarshalException("Not enough bytes to read a map");
-        }
-    }
-
-    /**
-     * Layout is: {@code <n><sk_1><k_1><sv_1><v_1>...<sk_n><k_n><sv_n><v_n> }
-     * where:
-     *   n is the number of elements
-     *   sk_i is the number of bytes composing the ith key k_i
-     *   k_i is the sk_i bytes composing the ith key
-     *   sv_i is the number of bytes composing the ith value v_i
-     *   v_i is the sv_i bytes composing the ith value
-     */
-    public ByteBuffer decompose(Map<K, V> value)
-    {
-        List<ByteBuffer> bbs = new ArrayList<ByteBuffer>(2 * value.size());
-        int size = 0;
-        for (Map.Entry<K, V> entry : value.entrySet())
-        {
-            ByteBuffer bbk = keys.decompose(entry.getKey());
-            ByteBuffer bbv = values.decompose(entry.getValue());
-            bbs.add(bbk);
-            bbs.add(bbv);
-            size += 4 + bbk.remaining() + bbv.remaining();
-        }
-        return pack(bbs, value.size(), size);
-    }
-
     @Override
     public TypeSerializer<Map<K, V>> getSerializer()
     {
-        return composer;
+        return serializer;
     }
 
     protected void appendToStringBuilder(StringBuilder sb)
@@ -144,7 +89,7 @@ public class MapType<K, V> extends CollectionType<Map<K, V>>
     }
 
     /**
-     * Creates the same output than deserialize, but from the internal representation.
+     * Creates the same output than serialize, but from the internal representation.
      */
     public ByteBuffer serialize(List<Pair<ByteBuffer, Column>> columns)
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/ReversedType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/ReversedType.java b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
index b111fa6..a292f3b 100644
--- a/src/java/org/apache/cassandra/db/marshal/ReversedType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
@@ -84,28 +84,12 @@ public class ReversedType<T> extends AbstractType<T>
         return baseType.fromString(source);
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        baseType.validate(bytes);
-    }
-
-    public T compose(ByteBuffer bytes)
-    {
-        return baseType.compose(bytes);
-    }
-
-    public ByteBuffer decompose(T value)
-    {
-        return baseType.decompose(value);
-    }
-
     @Override
     public CQL3Type asCQL3Type()
     {
         return baseType.asCQL3Type();
     }
 
-    @Override
     public TypeSerializer<T> getSerializer()
     {
         return baseType.getSerializer();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/SetType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/SetType.java b/src/java/org/apache/cassandra/db/marshal/SetType.java
index 4979e17..0f36ec1 100644
--- a/src/java/org/apache/cassandra/db/marshal/SetType.java
+++ b/src/java/org/apache/cassandra/db/marshal/SetType.java
@@ -33,7 +33,7 @@ public class SetType<T> extends CollectionType<Set<T>>
     private static final Map<AbstractType<?>, SetType> instances = new HashMap<AbstractType<?>, SetType>();
 
     public final AbstractType<T> elements;
-    private final SetSerializer<T> composer;
+    private final SetSerializer<T> serializer;
 
     public static SetType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
     {
@@ -59,7 +59,7 @@ public class SetType<T> extends CollectionType<Set<T>>
     {
         super(Kind.SET);
         this.elements = elements;
-        this.composer = SetSerializer.getInstance(elements.getSerializer());
+        this.serializer = SetSerializer.getInstance(elements.getSerializer());
     }
 
     public AbstractType<T> nameComparator()
@@ -72,19 +72,9 @@ public class SetType<T> extends CollectionType<Set<T>>
         return EmptyType.instance;
     }
 
-    public Set<T> compose(ByteBuffer bytes)
-    {
-        return composer.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(Set<T> value)
-    {
-        return composer.deserialize(value);
-    }
-
     public TypeSerializer<Set<T>> getSerializer()
     {
-        return composer;
+        return serializer;
     }
 
     protected void appendToStringBuilder(StringBuilder sb)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java b/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java
index d4f145e..51cf47a 100644
--- a/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java
+++ b/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java
@@ -38,16 +38,6 @@ public class TimeUUIDType extends AbstractType<UUID>
     {
     } // singleton
 
-    public UUID compose(ByteBuffer bytes)
-    {
-        return TimeUUIDSerializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(UUID value)
-    {
-        return TimeUUIDSerializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         if (o1.remaining() == 0)
@@ -93,11 +83,6 @@ public class TimeUUIDType extends AbstractType<UUID>
         return (o1.get(o1Pos + 3) & 0xFF) - (o2.get(o2Pos + 3) & 0xFF);
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return TimeUUIDSerializer.instance.getString(bytes);
-    }
-
     // This accepts dates are valid TimeUUID represensation, which is bogus
     // (see #4936) but kept for CQL2 for compatibility sake.
     @Override
@@ -164,18 +149,11 @@ public class TimeUUIDType extends AbstractType<UUID>
         return idBytes;
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        TimeUUIDSerializer.instance.validate(bytes);
-
-    }
-
     public CQL3Type asCQL3Type()
     {
         return CQL3Type.Native.TIMEUUID;
     }
 
-    @Override
     public TypeSerializer<UUID> getSerializer()
     {
         return TimeUUIDSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/TimestampType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/TimestampType.java b/src/java/org/apache/cassandra/db/marshal/TimestampType.java
index c525bdf..ae00840 100644
--- a/src/java/org/apache/cassandra/db/marshal/TimestampType.java
+++ b/src/java/org/apache/cassandra/db/marshal/TimestampType.java
@@ -46,26 +46,11 @@ public class TimestampType extends AbstractType<Date>
 
     private TimestampType() {} // singleton
 
-    public Date compose(ByteBuffer bytes)
-    {
-        return TimestampSerializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(Date value)
-    {
-        return TimestampSerializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         return LongType.compareLongs(o1, o2);
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return TimestampSerializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source) throws MarshalException
     {
       // Return an empty ByteBuffer for an empty string.
@@ -111,11 +96,6 @@ public class TimestampType extends AbstractType<Date>
       return millis;
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        TimestampSerializer.instance.validate(bytes);
-    }
-
     @Override
     public boolean isCompatibleWith(AbstractType<?> previous)
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/UTF8Type.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/UTF8Type.java b/src/java/org/apache/cassandra/db/marshal/UTF8Type.java
index 33284d7..0e18a45 100644
--- a/src/java/org/apache/cassandra/db/marshal/UTF8Type.java
+++ b/src/java/org/apache/cassandra/db/marshal/UTF8Type.java
@@ -30,36 +30,16 @@ public class UTF8Type extends AbstractType<String>
 
     UTF8Type() {} // singleton
 
-    public String compose(ByteBuffer bytes)
-    {
-        return UTF8Serializer.instance.serialize(bytes);
-    }
-
-    public ByteBuffer decompose(String value)
-    {
-        return UTF8Serializer.instance.deserialize(value);
-    }
-
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         return BytesType.bytesCompare(o1, o2);
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return UTF8Serializer.instance.getString(bytes);
-    }
-
     public ByteBuffer fromString(String source)
     {
         return decompose(source);
     }
 
-    public void validate(ByteBuffer bytes) throws MarshalException
-    {
-        UTF8Serializer.instance.validate(bytes);
-    }
-
     @Override
     public boolean isCompatibleWith(AbstractType<?> previous)
     {
@@ -73,7 +53,6 @@ public class UTF8Type extends AbstractType<String>
         return CQL3Type.Native.TEXT;
     }
 
-    @Override
     public TypeSerializer<String> getSerializer()
     {
         return UTF8Serializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/db/marshal/UUIDType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/UUIDType.java b/src/java/org/apache/cassandra/db/marshal/UUIDType.java
index 21e20b7..ebb7021 100644
--- a/src/java/org/apache/cassandra/db/marshal/UUIDType.java
+++ b/src/java/org/apache/cassandra/db/marshal/UUIDType.java
@@ -158,27 +158,6 @@ public class UUIDType extends AbstractType<UUID>
         return (o1.get(o1Pos + 3) & 0xFF) - (o2.get(o2Pos + 3) & 0xFF);
     }
 
-    public UUID compose(ByteBuffer bytes)
-    {
-
-        return UUIDSerializer.instance.serialize(bytes);
-    }
-
-    public void validate(ByteBuffer bytes)
-    {
-        UUIDSerializer.instance.validate(bytes);
-    }
-
-    public String getString(ByteBuffer bytes)
-    {
-        return UUIDSerializer.instance.getString(bytes);
-    }
-
-    public ByteBuffer decompose(UUID value)
-    {
-        return UUIDSerializer.instance.deserialize(value);
-    }
-
     @Override
     public ByteBuffer fromString(String source) throws MarshalException
     {
@@ -239,7 +218,6 @@ public class UUIDType extends AbstractType<UUID>
         return CQL3Type.Native.UUID;
     }
 
-    @Override
     public TypeSerializer<UUID> getSerializer()
     {
         return UUIDSerializer.instance;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/AbstractTextSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/AbstractTextSerializer.java b/src/java/org/apache/cassandra/serializers/AbstractTextSerializer.java
index a132ce4..f1de6a4 100644
--- a/src/java/org/apache/cassandra/serializers/AbstractTextSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/AbstractTextSerializer.java
@@ -32,17 +32,7 @@ public abstract class AbstractTextSerializer implements TypeSerializer<String>
         this.charset = charset;
     }
 
-    public String serialize(ByteBuffer bytes)
-    {
-        return getString(bytes);
-    }
-
-    public ByteBuffer deserialize(String value)
-    {
-        return ByteBufferUtil.bytes(value, charset);
-    }
-
-    public String getString(ByteBuffer bytes)
+    public String deserialize(ByteBuffer bytes)
     {
         try
         {
@@ -54,6 +44,11 @@ public abstract class AbstractTextSerializer implements TypeSerializer<String>
         }
     }
 
+    public ByteBuffer serialize(String value)
+    {
+        return ByteBufferUtil.bytes(value, charset);
+    }
+
     public String toString(String value)
     {
         return value;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/BooleanSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/BooleanSerializer.java b/src/java/org/apache/cassandra/serializers/BooleanSerializer.java
index f2add98..dffecd6 100644
--- a/src/java/org/apache/cassandra/serializers/BooleanSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/BooleanSerializer.java
@@ -28,13 +28,16 @@ public class BooleanSerializer implements TypeSerializer<Boolean>
 
     public static final BooleanSerializer instance = new BooleanSerializer();
 
-    public Boolean serialize(ByteBuffer bytes)
+    public Boolean deserialize(ByteBuffer bytes)
     {
+        if (bytes.remaining() == 0)
+            return null;
+
         byte value = bytes.get(bytes.position());
         return value != 0;
     }
 
-    public ByteBuffer deserialize(Boolean value)
+    public ByteBuffer serialize(Boolean value)
     {
         return (value == null) ? ByteBufferUtil.EMPTY_BYTE_BUFFER
                 : value ? TRUE : FALSE; // false
@@ -46,21 +49,6 @@ public class BooleanSerializer implements TypeSerializer<Boolean>
             throw new MarshalException(String.format("Expected 1 or 0 byte value (%d)", bytes.remaining()));
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        if (bytes.remaining() == 0)
-        {
-            return Boolean.FALSE.toString();
-        }
-        if (bytes.remaining() != 1)
-        {
-            throw new MarshalException("A boolean is stored in exactly 1 byte: " + bytes.remaining());
-        }
-        byte value = bytes.get(bytes.position());
-
-        return value == 0 ? Boolean.FALSE.toString() : Boolean.TRUE.toString();
-    }
-
     public String toString(Boolean value)
     {
         return value == null ? "" : value.toString();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/BytesSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/BytesSerializer.java b/src/java/org/apache/cassandra/serializers/BytesSerializer.java
index 6504f84..4dcaa82 100644
--- a/src/java/org/apache/cassandra/serializers/BytesSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/BytesSerializer.java
@@ -43,14 +43,9 @@ public class BytesSerializer implements TypeSerializer<ByteBuffer>
         // all bytes are legal.
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return ByteBufferUtil.bytesToHex(bytes);
-    }
-
     public String toString(ByteBuffer value)
     {
-        return getString(value);
+        return ByteBufferUtil.bytesToHex(value);
     }
 
     public Class<ByteBuffer> getType()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/CollectionSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/CollectionSerializer.java b/src/java/org/apache/cassandra/serializers/CollectionSerializer.java
index 563e88b..9d4e4a4 100644
--- a/src/java/org/apache/cassandra/serializers/CollectionSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/CollectionSerializer.java
@@ -28,11 +28,6 @@ public abstract class CollectionSerializer<T> implements TypeSerializer<T>
         // The collection is not currently being properly validated.
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return BytesSerializer.instance.getString(bytes);
-    }
-
     // Utilitary method
     protected static ByteBuffer pack(List<ByteBuffer> buffers, int elements, int size)
     {
@@ -54,7 +49,6 @@ public abstract class CollectionSerializer<T> implements TypeSerializer<T>
         return pack(buffers, elements, size);
     }
 
-
     protected static int getUnsignedShort(ByteBuffer bb)
     {
         int length = (bb.get() & 0xFF) << 8;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/DecimalSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/DecimalSerializer.java b/src/java/org/apache/cassandra/serializers/DecimalSerializer.java
index 21031b0..0ffea9e 100644
--- a/src/java/org/apache/cassandra/serializers/DecimalSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/DecimalSerializer.java
@@ -27,9 +27,9 @@ public class DecimalSerializer implements TypeSerializer<BigDecimal>
 {
     public static final DecimalSerializer instance = new DecimalSerializer();
 
-    public BigDecimal serialize(ByteBuffer bytes)
+    public BigDecimal deserialize(ByteBuffer bytes)
     {
-        if (bytes == null)
+        if (bytes == null || bytes.remaining() == 0)
             return null;
 
         // do not consume the contents of the ByteBuffer
@@ -42,7 +42,7 @@ public class DecimalSerializer implements TypeSerializer<BigDecimal>
         return new BigDecimal(bi, scale);
     }
 
-    public ByteBuffer deserialize(BigDecimal value)
+    public ByteBuffer serialize(BigDecimal value)
     {
         if (value == null)
             return ByteBufferUtil.EMPTY_BYTE_BUFFER;
@@ -63,16 +63,9 @@ public class DecimalSerializer implements TypeSerializer<BigDecimal>
 
     public void validate(ByteBuffer bytes) throws MarshalException
     {
-        // no useful check for invalid decimals.
-    }
-
-    public String getString(ByteBuffer bytes)
-    {
-        if (bytes.remaining() == 0)
-        {
-            return "";
-        }
-        return serialize(bytes).toPlainString();
+        // We at least store the scale.
+        if (bytes.remaining() != 0 && bytes.remaining() < 4)
+            throw new MarshalException(String.format("Expected 0 or at least 4 bytes (%d)", bytes.remaining()));
     }
 
     public String toString(BigDecimal value)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/DoubleSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/DoubleSerializer.java b/src/java/org/apache/cassandra/serializers/DoubleSerializer.java
index 9fbd627..13ca33b 100644
--- a/src/java/org/apache/cassandra/serializers/DoubleSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/DoubleSerializer.java
@@ -26,12 +26,14 @@ public class DoubleSerializer implements TypeSerializer<Double>
 {
     public static final DoubleSerializer instance = new DoubleSerializer();
 
-    public Double serialize(ByteBuffer bytes)
+    public Double deserialize(ByteBuffer bytes)
     {
+        if (bytes.remaining() == 0)
+            return null;
         return ByteBufferUtil.toDouble(bytes);
     }
 
-    public ByteBuffer deserialize(Double value)
+    public ByteBuffer serialize(Double value)
     {
         return (value == null) ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
     }
@@ -42,20 +44,6 @@ public class DoubleSerializer implements TypeSerializer<Double>
             throw new MarshalException(String.format("Expected 8 or 0 byte value for a double (%d)", bytes.remaining()));
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        if (bytes.remaining() == 0)
-        {
-            return "";
-        }
-        if (bytes.remaining() != 8)
-        {
-            throw new MarshalException("A double is exactly 8 bytes : " + bytes.remaining());
-        }
-
-        return String.valueOf(ByteBufferUtil.toDouble(bytes));
-    }
-
     public String toString(Double value)
     {
         return value == null ? "" : value.toString();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/EmptySerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/EmptySerializer.java b/src/java/org/apache/cassandra/serializers/EmptySerializer.java
index 2e082b6..2ccecc5 100644
--- a/src/java/org/apache/cassandra/serializers/EmptySerializer.java
+++ b/src/java/org/apache/cassandra/serializers/EmptySerializer.java
@@ -26,12 +26,12 @@ public class EmptySerializer implements TypeSerializer<Void>
 {
     public static final EmptySerializer instance = new EmptySerializer();
 
-    public Void serialize(ByteBuffer bytes)
+    public Void deserialize(ByteBuffer bytes)
     {
         return null;
     }
 
-    public ByteBuffer deserialize(Void value)
+    public ByteBuffer serialize(Void value)
     {
         return ByteBufferUtil.EMPTY_BYTE_BUFFER;
     }
@@ -42,11 +42,6 @@ public class EmptySerializer implements TypeSerializer<Void>
             throw new MarshalException("EmptyType only accept empty values");
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return "";
-    }
-
     public String toString(Void value)
     {
         return "";

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/FloatSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/FloatSerializer.java b/src/java/org/apache/cassandra/serializers/FloatSerializer.java
index 35fc528..94a24fe 100644
--- a/src/java/org/apache/cassandra/serializers/FloatSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/FloatSerializer.java
@@ -26,12 +26,15 @@ public class FloatSerializer implements TypeSerializer<Float>
 {
     public static final FloatSerializer instance = new FloatSerializer();
 
-    public Float serialize(ByteBuffer bytes)
+    public Float deserialize(ByteBuffer bytes)
     {
+        if (bytes.remaining() == 0)
+            return null;
+
         return ByteBufferUtil.toFloat(bytes);
     }
 
-    public ByteBuffer deserialize(Float value)
+    public ByteBuffer serialize(Float value)
     {
         return (value == null) ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
     }
@@ -42,20 +45,6 @@ public class FloatSerializer implements TypeSerializer<Float>
             throw new MarshalException(String.format("Expected 4 or 0 byte value for a float (%d)", bytes.remaining()));
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        if (bytes.remaining() == 0)
-        {
-            return "";
-        }
-        if (bytes.remaining() != 4)
-        {
-            throw new MarshalException("A float is exactly 4 bytes : " + bytes.remaining());
-        }
-
-        return String.valueOf(ByteBufferUtil.toFloat(bytes));
-    }
-
     public String toString(Float value)
     {
         return value == null ? "" : String.valueOf(value);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/InetAddressSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/InetAddressSerializer.java b/src/java/org/apache/cassandra/serializers/InetAddressSerializer.java
index 39d9a9e..f5406f2 100644
--- a/src/java/org/apache/cassandra/serializers/InetAddressSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/InetAddressSerializer.java
@@ -28,8 +28,11 @@ public class InetAddressSerializer implements TypeSerializer<InetAddress>
 {
     public static final InetAddressSerializer instance = new InetAddressSerializer();
 
-    public InetAddress serialize(ByteBuffer bytes)
+    public InetAddress deserialize(ByteBuffer bytes)
     {
+        if (bytes.remaining() == 0)
+            return null;
+
         try
         {
             return InetAddress.getByAddress(ByteBufferUtil.getArray(bytes));
@@ -40,13 +43,16 @@ public class InetAddressSerializer implements TypeSerializer<InetAddress>
         }
     }
 
-    public ByteBuffer deserialize(InetAddress value)
+    public ByteBuffer serialize(InetAddress value)
     {
-        return ByteBuffer.wrap(value.getAddress());
+        return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBuffer.wrap(value.getAddress());
     }
 
     public void validate(ByteBuffer bytes) throws MarshalException
     {
+        if (bytes.remaining() == 0)
+            return;
+
         try
         {
             InetAddress.getByAddress(ByteBufferUtil.getArray(bytes));
@@ -57,11 +63,6 @@ public class InetAddressSerializer implements TypeSerializer<InetAddress>
         }
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        return serialize(bytes).getHostAddress();
-    }
-
     public String toString(InetAddress value)
     {
         return value.getHostAddress();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/Int32Serializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/Int32Serializer.java b/src/java/org/apache/cassandra/serializers/Int32Serializer.java
index a6399cd..73e350f 100644
--- a/src/java/org/apache/cassandra/serializers/Int32Serializer.java
+++ b/src/java/org/apache/cassandra/serializers/Int32Serializer.java
@@ -26,12 +26,12 @@ public class Int32Serializer implements TypeSerializer<Integer>
 {
     public static final Int32Serializer instance = new Int32Serializer();
 
-    public Integer serialize(ByteBuffer bytes)
+    public Integer deserialize(ByteBuffer bytes)
     {
-        return ByteBufferUtil.toInt(bytes);
+        return bytes.remaining() == 0 ? null : ByteBufferUtil.toInt(bytes);
     }
 
-    public ByteBuffer deserialize(Integer value)
+    public ByteBuffer serialize(Integer value)
     {
         return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
     }
@@ -42,20 +42,6 @@ public class Int32Serializer implements TypeSerializer<Integer>
             throw new MarshalException(String.format("Expected 4 or 0 byte int (%d)", bytes.remaining()));
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        if (bytes.remaining() == 0)
-        {
-            return "";
-        }
-        if (bytes.remaining() != 4)
-        {
-            throw new MarshalException("A int is exactly 4 bytes: " + bytes.remaining());
-        }
-
-        return String.valueOf(ByteBufferUtil.toInt(bytes));
-    }
-
     public String toString(Integer value)
     {
         return value == null ? "" : String.valueOf(value);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/IntegerSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/IntegerSerializer.java b/src/java/org/apache/cassandra/serializers/IntegerSerializer.java
index 01ecb36..b028cd4 100644
--- a/src/java/org/apache/cassandra/serializers/IntegerSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/IntegerSerializer.java
@@ -27,12 +27,12 @@ public class IntegerSerializer implements TypeSerializer<BigInteger>
 {
     public static final IntegerSerializer instance = new IntegerSerializer();
 
-    public BigInteger serialize(ByteBuffer bytes)
+    public BigInteger deserialize(ByteBuffer bytes)
     {
         return new BigInteger(ByteBufferUtil.getArray(bytes));
     }
 
-    public ByteBuffer deserialize(BigInteger value)
+    public ByteBuffer serialize(BigInteger value)
     {
         return ByteBuffer.wrap(value.toByteArray());
     }
@@ -42,16 +42,6 @@ public class IntegerSerializer implements TypeSerializer<BigInteger>
         // no invalid integers.
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        if (bytes.remaining() == 0)
-        {
-            return "";
-        }
-
-        return new BigInteger(ByteBufferUtil.getArray(bytes)).toString(10);
-    }
-
     public String toString(BigInteger value)
     {
         return value.toString(10);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/ListSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/ListSerializer.java b/src/java/org/apache/cassandra/serializers/ListSerializer.java
index 94ffbd0..043f254 100644
--- a/src/java/org/apache/cassandra/serializers/ListSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/ListSerializer.java
@@ -45,7 +45,7 @@ public class ListSerializer<T> extends CollectionSerializer<List<T>>
         this.elements = elements;
     }
 
-    public List<T> serialize(ByteBuffer bytes)
+    public List<T> deserialize(ByteBuffer bytes)
     {
         try
         {
@@ -59,7 +59,7 @@ public class ListSerializer<T> extends CollectionSerializer<List<T>>
                 input.get(data);
                 ByteBuffer databb = ByteBuffer.wrap(data);
                 elements.validate(databb);
-                l.add(elements.serialize(databb));
+                l.add(elements.deserialize(databb));
             }
             return l;
         }
@@ -76,13 +76,13 @@ public class ListSerializer<T> extends CollectionSerializer<List<T>>
      *   s_i is the number of bytes composing the ith element
      *   b_i is the s_i bytes composing the ith element
      */
-    public ByteBuffer deserialize(List<T> value)
+    public ByteBuffer serialize(List<T> value)
     {
         List<ByteBuffer> bbs = new ArrayList<ByteBuffer>(value.size());
         int size = 0;
         for (T elt : value)
         {
-            ByteBuffer bb = elements.deserialize(elt);
+            ByteBuffer bb = elements.serialize(elt);
             bbs.add(bb);
             size += 2 + bb.remaining();
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/LongSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/LongSerializer.java b/src/java/org/apache/cassandra/serializers/LongSerializer.java
index b103b03..277c395 100644
--- a/src/java/org/apache/cassandra/serializers/LongSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/LongSerializer.java
@@ -26,14 +26,14 @@ public class LongSerializer implements TypeSerializer<Long>
 {
     public static final LongSerializer instance = new LongSerializer();
 
-    public Long serialize(ByteBuffer bytes)
+    public Long deserialize(ByteBuffer bytes)
     {
-        return ByteBufferUtil.toLong(bytes);
+        return bytes.remaining() == 0 ? null : ByteBufferUtil.toLong(bytes);
     }
 
-    public ByteBuffer deserialize(Long value)
+    public ByteBuffer serialize(Long value)
     {
-        return ByteBufferUtil.bytes(value);
+        return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
     }
 
     public void validate(ByteBuffer bytes) throws MarshalException
@@ -42,20 +42,6 @@ public class LongSerializer implements TypeSerializer<Long>
             throw new MarshalException(String.format("Expected 8 or 0 byte long (%d)", bytes.remaining()));
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        if (bytes.remaining() == 0)
-        {
-            return "";
-        }
-        if (bytes.remaining() != 8)
-        {
-            throw new MarshalException("A long is exactly 8 bytes: " + bytes.remaining());
-        }
-
-        return String.valueOf(ByteBufferUtil.toLong(bytes));
-    }
-
     public String toString(Long value)
     {
         return String.valueOf(value);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/MapSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/MapSerializer.java b/src/java/org/apache/cassandra/serializers/MapSerializer.java
index d7526e4..39b3cba 100644
--- a/src/java/org/apache/cassandra/serializers/MapSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/MapSerializer.java
@@ -50,7 +50,7 @@ public class MapSerializer<K, V> extends CollectionSerializer<Map<K, V>>
         this.values = values;
     }
 
-    public Map<K, V> serialize(ByteBuffer bytes)
+    public Map<K, V> deserialize(ByteBuffer bytes)
     {
         try
         {
@@ -71,7 +71,7 @@ public class MapSerializer<K, V> extends CollectionSerializer<Map<K, V>>
                 ByteBuffer vbb = ByteBuffer.wrap(datav);
                 values.validate(vbb);
 
-                m.put(keys.serialize(kbb), values.serialize(vbb));
+                m.put(keys.deserialize(kbb), values.deserialize(vbb));
             }
             return m;
         }
@@ -81,14 +81,23 @@ public class MapSerializer<K, V> extends CollectionSerializer<Map<K, V>>
         }
     }
 
-    public ByteBuffer deserialize(Map<K, V> value)
+    /**
+     * Layout is: {@code <n><sk_1><k_1><sv_1><v_1>...<sk_n><k_n><sv_n><v_n> }
+     * where:
+     *   n is the number of elements
+     *   sk_i is the number of bytes composing the ith key k_i
+     *   k_i is the sk_i bytes composing the ith key
+     *   sv_i is the number of bytes composing the ith value v_i
+     *   v_i is the sv_i bytes composing the ith value
+     */
+    public ByteBuffer serialize(Map<K, V> value)
     {
         List<ByteBuffer> bbs = new ArrayList<ByteBuffer>(2 * value.size());
         int size = 0;
         for (Map.Entry<K, V> entry : value.entrySet())
         {
-            ByteBuffer bbk = keys.deserialize(entry.getKey());
-            ByteBuffer bbv = values.deserialize(entry.getValue());
+            ByteBuffer bbk = keys.serialize(entry.getKey());
+            ByteBuffer bbv = values.serialize(entry.getValue());
             bbs.add(bbk);
             bbs.add(bbv);
             size += 4 + bbk.remaining() + bbv.remaining();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/SetSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/SetSerializer.java b/src/java/org/apache/cassandra/serializers/SetSerializer.java
index be33318..5595077 100644
--- a/src/java/org/apache/cassandra/serializers/SetSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/SetSerializer.java
@@ -45,7 +45,7 @@ public class SetSerializer<T> extends CollectionSerializer<Set<T>>
         this.elements = elements;
     }
 
-    public Set<T> serialize(ByteBuffer bytes)
+    public Set<T> deserialize(ByteBuffer bytes)
     {
         try
         {
@@ -59,7 +59,7 @@ public class SetSerializer<T> extends CollectionSerializer<Set<T>>
                 input.get(data);
                 ByteBuffer databb = ByteBuffer.wrap(data);
                 elements.validate(databb);
-                l.add(elements.serialize(databb));
+                l.add(elements.deserialize(databb));
             }
             return l;
         }
@@ -76,13 +76,13 @@ public class SetSerializer<T> extends CollectionSerializer<Set<T>>
      *   s_i is the number of bytes composing the ith element
      *   b_i is the s_i bytes composing the ith element
      */
-    public ByteBuffer deserialize(Set<T> value)
+    public ByteBuffer serialize(Set<T> value)
     {
         List<ByteBuffer> bbs = new ArrayList<ByteBuffer>(value.size());
         int size = 0;
         for (T elt : value)
         {
-            ByteBuffer bb = elements.deserialize(elt);
+            ByteBuffer bb = elements.serialize(elt);
             bbs.add(bb);
             size += 2 + bb.remaining();
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/TimestampSerializer.java b/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
index 49766c7..77bd59a 100644
--- a/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
@@ -50,18 +50,14 @@ public class TimestampSerializer implements TypeSerializer<Date>
 
     public static final TimestampSerializer instance = new TimestampSerializer();
 
-    public Date serialize(ByteBuffer bytes)
+    public Date deserialize(ByteBuffer bytes)
     {
-        return bytes.remaining() > 0
-                ? new Date(ByteBufferUtil.toLong(bytes))
-                : null;
+        return bytes.remaining() == 0 ? null : new Date(ByteBufferUtil.toLong(bytes));
     }
 
-    public ByteBuffer deserialize(Date value)
+    public ByteBuffer serialize(Date value)
     {
-        return (value == null)
-                ? ByteBufferUtil.EMPTY_BYTE_BUFFER
-                : ByteBufferUtil.bytes(value.getTime());
+        return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value.getTime());
     }
 
     public void validate(ByteBuffer bytes) throws MarshalException
@@ -70,21 +66,6 @@ public class TimestampSerializer implements TypeSerializer<Date>
             throw new MarshalException(String.format("Expected 8 or 0 byte long for date (%d)", bytes.remaining()));
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        if (bytes.remaining() == 0)
-        {
-            return "";
-        }
-        if (bytes.remaining() != 8)
-        {
-            throw new MarshalException("A date is exactly 8 bytes (stored as a long): " + bytes.remaining());
-        }
-
-        // uses ISO-8601 formatted string
-        return FORMATTER.get().format(new Date(ByteBufferUtil.toLong(bytes)));
-    }
-
     public String toString(Date value)
     {
         return FORMATTER.get().format(value);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/TypeSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/TypeSerializer.java b/src/java/org/apache/cassandra/serializers/TypeSerializer.java
index 9d30508..7b037c0 100644
--- a/src/java/org/apache/cassandra/serializers/TypeSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/TypeSerializer.java
@@ -22,14 +22,15 @@ import java.nio.ByteBuffer;
 
 public interface TypeSerializer<T>
 {
-    public T serialize(ByteBuffer bytes);
-    public ByteBuffer deserialize(T value);
+    public ByteBuffer serialize(T value);
+    public T deserialize(ByteBuffer bytes);
 
-
-    /* validate that the byte array is a valid sequence for the type we are supposed to be comparing */
+    /*
+     * Validate that the byte array is a valid sequence for the type this represents.
+     * This guarantees deserialize() can be called without errors.
+     */
     public void validate(ByteBuffer bytes) throws MarshalException;
 
-    public String getString(ByteBuffer bytes);
     public String toString(T value);
 
     public Class<T> getType();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/serializers/UUIDSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/UUIDSerializer.java b/src/java/org/apache/cassandra/serializers/UUIDSerializer.java
index 4bfd6d5..0e64fca 100644
--- a/src/java/org/apache/cassandra/serializers/UUIDSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/UUIDSerializer.java
@@ -17,23 +17,24 @@
  */
 package org.apache.cassandra.serializers;
 
-import org.apache.cassandra.utils.UUIDGen;
-
 import java.nio.ByteBuffer;
 import java.util.UUID;
 
+import org.apache.cassandra.utils.ByteBufferUtil;
+import org.apache.cassandra.utils.UUIDGen;
+
 public class UUIDSerializer implements TypeSerializer<UUID>
 {
     public static final UUIDSerializer instance = new UUIDSerializer();
 
-    public UUID serialize(ByteBuffer bytes)
+    public UUID deserialize(ByteBuffer bytes)
     {
-        return UUIDGen.getUUID(bytes);
+        return bytes.remaining() == 0 ? null : UUIDGen.getUUID(bytes);
     }
 
-    public ByteBuffer deserialize(UUID value)
+    public ByteBuffer serialize(UUID value)
     {
-        return ByteBuffer.wrap(UUIDGen.decompose(value));
+        return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBuffer.wrap(UUIDGen.decompose(value));
     }
 
     public void validate(ByteBuffer bytes) throws MarshalException
@@ -43,20 +44,6 @@ public class UUIDSerializer implements TypeSerializer<UUID>
         // not sure what the version should be for this.
     }
 
-    public String getString(ByteBuffer bytes)
-    {
-        if (bytes.remaining() == 0)
-        {
-            return "";
-        }
-        if (bytes.remaining() != 16)
-        {
-            throw new MarshalException("UUIDs must be exactly 16 bytes");
-        }
-        UUID uuid = UUIDGen.getUUID(bytes);
-        return uuid.toString();
-    }
-
     public String toString(UUID value)
     {
         return value.toString();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/tools/Shuffle.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/Shuffle.java b/src/java/org/apache/cassandra/tools/Shuffle.java
index d89337b..502c238 100644
--- a/src/java/org/apache/cassandra/tools/Shuffle.java
+++ b/src/java/org/apache/cassandra/tools/Shuffle.java
@@ -389,7 +389,7 @@ public class Shuffle extends AbstractJmxClient
 
                 ByteBuffer tokenBytes = ByteBuffer.wrap(row.getColumns().get(0).getValue());
                 ByteBuffer requestedAt = ByteBuffer.wrap(row.getColumns().get(1).getValue());
-                Date time = TimestampSerializer.instance.serialize(requestedAt);
+                Date time = TimestampSerializer.instance.deserialize(requestedAt);
                 Token<?> token = partitioner.getTokenFactory().fromByteArray(tokenBytes);
 
                 writeln("%-42s %-15s %s", token.toString(), host, time.toString());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/src/java/org/apache/cassandra/utils/BooleanSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/BooleanSerializer.java b/src/java/org/apache/cassandra/utils/BooleanSerializer.java
index 88db2fc..0c37f67 100644
--- a/src/java/org/apache/cassandra/utils/BooleanSerializer.java
+++ b/src/java/org/apache/cassandra/utils/BooleanSerializer.java
@@ -41,4 +41,4 @@ public class BooleanSerializer implements IVersionedSerializer<Boolean>
     {
         return 1;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/test/data/serialization/2.0/db.RowMutation.bin
----------------------------------------------------------------------
diff --git a/test/data/serialization/2.0/db.RowMutation.bin b/test/data/serialization/2.0/db.RowMutation.bin
index 4b525d3..698b0b6 100644
Binary files a/test/data/serialization/2.0/db.RowMutation.bin and b/test/data/serialization/2.0/db.RowMutation.bin differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/daff1fce/test/unit/org/apache/cassandra/cql/jdbc/JdbcDecimalTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql/jdbc/JdbcDecimalTest.java b/test/unit/org/apache/cassandra/cql/jdbc/JdbcDecimalTest.java
index cb88ae8..e7ab712 100644
--- a/test/unit/org/apache/cassandra/cql/jdbc/JdbcDecimalTest.java
+++ b/test/unit/org/apache/cassandra/cql/jdbc/JdbcDecimalTest.java
@@ -33,8 +33,8 @@ public class JdbcDecimalTest
         BigDecimal expected = new BigDecimal("123456789123456789.987654321");
         DecimalSerializer decimal = new DecimalSerializer();
         
-        ByteBuffer buffer = decimal.deserialize(expected);
-        BigDecimal actual = decimal.serialize(buffer);
+        ByteBuffer buffer = decimal.serialize(expected);
+        BigDecimal actual = decimal.deserialize(buffer);
         Assert.assertEquals(expected, actual);
     }
 }


Mime
View raw message