cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1095223 - /cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/
Date Tue, 19 Apr 2011 21:54:08 GMT
Author: jbellis
Date: Tue Apr 19 21:54:07 2011
New Revision: 1095223

URL: http://svn.apache.org/viewvc?rev=1095223&view=rev
Log:
fix merging r1088800 from 0.7

Modified:
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/AbstractType.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/AsciiType.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/BytesType.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/IntegerType.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LexicalUUIDType.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LongType.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/UTF8Type.java

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/AbstractType.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/AbstractType.java?rev=1095223&r1=1095222&r2=1095223&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/AbstractType.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/AbstractType.java
Tue Apr 19 21:54:07 2011
@@ -93,6 +93,8 @@ public abstract class AbstractType<T> im
     }
     
     public abstract T compose(ByteBuffer bytes);
+    
+    public abstract ByteBuffer decompose(T value);
 
     /** get a string representation of a particular type. */
     public abstract String toString(T t);

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/AsciiType.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/AsciiType.java?rev=1095223&r1=1095222&r2=1095223&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/AsciiType.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/AsciiType.java
Tue Apr 19 21:54:07 2011
@@ -32,6 +32,12 @@ public class AsciiType extends AbstractT
 {
     public static final AsciiType instance = new AsciiType();
 
+    public static AsciiType getInstance()
+    {
+        return instance;
+    }
+
+
     AsciiType() {} // singleton
 
     public String getString(ByteBuffer bytes)
@@ -61,9 +67,14 @@ public class AsciiType extends AbstractT
         return getString(bytes);
     }
 
+    public ByteBuffer decompose(String value)
+    {
+        return ByteBufferUtil.bytes(value, Charsets.US_ASCII);
+    }
+
     public ByteBuffer fromString(String source)
     {
-        return ByteBufferUtil.bytes(source, Charsets.US_ASCII);
+        return decompose(source);
     }
 
     public void validate(ByteBuffer bytes) throws MarshalException

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/BytesType.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/BytesType.java?rev=1095223&r1=1095222&r2=1095223&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/BytesType.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/BytesType.java
Tue Apr 19 21:54:07 2011
@@ -30,18 +30,28 @@ public class BytesType extends AbstractT
 {
     public static final BytesType instance = new BytesType();
 
+    public static BytesType getInstance()
+    {
+        return instance;
+    }
+
     BytesType() {} // singleton
 
     public ByteBuffer compose(ByteBuffer bytes)
     {
         return bytes.duplicate();
     }
+
+    public ByteBuffer decompose(ByteBuffer value)
+    {
+        return value;
+    }
     
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         return BytesType.bytesCompare(o1, o2);
     }
-    
+
     public static int bytesCompare(ByteBuffer o1, ByteBuffer o2)
     {
         if(null == o1){

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/IntegerType.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/IntegerType.java?rev=1095223&r1=1095222&r2=1095223&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/IntegerType.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/IntegerType.java
Tue Apr 19 21:54:07 2011
@@ -29,6 +29,11 @@ public final class IntegerType extends A
 {
     public static final IntegerType instance = new IntegerType();
 
+    public static IntegerType getInstance()
+    {
+        return instance;
+    }
+
     private static int findMostSignificantByte(ByteBuffer bytes)
     {
         int len = bytes.remaining() - 1;
@@ -62,6 +67,11 @@ public final class IntegerType extends A
         return new BigInteger(ByteBufferUtil.getArray(bytes));
     }
 
+    public ByteBuffer decompose(BigInteger value)
+    {
+        return ByteBuffer.wrap(value.toByteArray());
+    }
+
     public int compare(ByteBuffer lhs, ByteBuffer rhs)
     {
         int lhsLen = lhs.remaining();
@@ -152,7 +162,7 @@ public final class IntegerType extends A
             throw new MarshalException(String.format("unable to make int from '%s'", source),
e);
         }
 
-        return ByteBuffer.wrap(integerType.toByteArray());
+        return decompose(integerType);
     }
 
     public void validate(ByteBuffer bytes) throws MarshalException

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LexicalUUIDType.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LexicalUUIDType.java?rev=1095223&r1=1095222&r2=1095223&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LexicalUUIDType.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LexicalUUIDType.java
Tue Apr 19 21:54:07 2011
@@ -31,6 +31,11 @@ public class LexicalUUIDType extends Abs
 {
     public static final LexicalUUIDType instance = new LexicalUUIDType();
 
+    public static LexicalUUIDType getInstance()
+    {
+        return instance;
+    }
+
     LexicalUUIDType() {} // singleton
 
     public UUID compose(ByteBuffer bytes)
@@ -38,6 +43,11 @@ public class LexicalUUIDType extends Abs
         return UUIDGen.getUUID(bytes);
     }
 
+    public ByteBuffer decompose(UUID value)
+    {
+        return ByteBuffer.wrap(UUIDGen.decompose(value));
+    }
+
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         if (o1.remaining() == 0)
@@ -78,7 +88,7 @@ public class LexicalUUIDType extends Abs
 
         try
         {
-            return ByteBuffer.wrap(UUIDGen.decompose(UUID.fromString(source)));
+            return decompose(UUID.fromString(source));
         }
         catch (IllegalArgumentException e)
         {

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java?rev=1095223&r1=1095222&r2=1095223&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
Tue Apr 19 21:54:07 2011
@@ -43,6 +43,11 @@ public class LocalByPartionerType<T exte
         throw new UnsupportedOperationException("You can't do this with a local partitioner.");
     }
 
+    public ByteBuffer decompose(ByteBuffer bytes)
+    {
+        throw new UnsupportedOperationException("You can't do this with a local partitioner.");
+    }
+
     public String getString(ByteBuffer bytes)
     {
         return ByteBufferUtil.bytesToHex(bytes);

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LongType.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LongType.java?rev=1095223&r1=1095222&r2=1095223&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LongType.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/LongType.java
Tue Apr 19 21:54:07 2011
@@ -36,6 +36,16 @@ public class LongType extends AbstractTy
         return ByteBufferUtil.toLong(bytes);
     }
 
+    public ByteBuffer decompose(Long value)
+    {
+        return ByteBufferUtil.bytes(value);
+    }
+
+    public static LongType getInstance()
+    {
+        return instance;
+    }
+
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         if (o1.remaining() == 0)
@@ -91,7 +101,7 @@ public class LongType extends AbstractTy
             throw new MarshalException(String.format("unable to make long from '%s'", source),
e);
         }
 
-        return ByteBufferUtil.bytes(longType);
+        return decompose(longType);
     }
 
     public void validate(ByteBuffer bytes) throws MarshalException

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java?rev=1095223&r1=1095222&r2=1095223&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java
Tue Apr 19 21:54:07 2011
@@ -33,8 +33,13 @@ import org.apache.commons.lang.time.Date
 
 public class TimeUUIDType extends AbstractType<UUID>
 {
-    
     public static final TimeUUIDType instance = new TimeUUIDType();
+
+    public static TimeUUIDType getInstance()
+    {
+        return instance;
+    }
+
     static final Pattern regexPattern = Pattern.compile("[A-Fa-f0-9]{8}\\-[A-Fa-f0-9]{4}\\-[A-Fa-f0-9]{4}\\-[A-Fa-f0-9]{4}\\-[A-Fa-f0-9]{12}");
     static final String[] iso8601Patterns = new String[] {
         "yyyy-MM-dd HH:mm",
@@ -56,6 +61,11 @@ public class TimeUUIDType extends Abstra
         return UUIDGen.getUUID(bytes);
     }
 
+    public ByteBuffer decompose(UUID value)
+    {
+        return ByteBuffer.wrap(UUIDGen.decompose(value));
+    }
+
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         if (o1.remaining() == 0)
@@ -139,7 +149,7 @@ public class TimeUUIDType extends Abstra
             try
             {
                 uuid = UUID.fromString(source);
-                idBytes = ByteBuffer.wrap(UUIDGen.decompose(uuid));
+                idBytes = decompose(uuid);
             }
             catch (IllegalArgumentException e)
             {

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/UTF8Type.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/UTF8Type.java?rev=1095223&r1=1095222&r2=1095223&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/UTF8Type.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/marshal/UTF8Type.java
Tue Apr 19 21:54:07 2011
@@ -23,6 +23,7 @@ package org.apache.cassandra.db.marshal;
 import java.nio.ByteBuffer;
 import java.nio.charset.CharacterCodingException;
 
+import com.google.common.base.Charsets;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 public class UTF8Type extends AbstractType<String>
@@ -31,11 +32,21 @@ public class UTF8Type extends AbstractTy
 
     UTF8Type() {} // singleton
 
+    public static UTF8Type getInstance()
+    {
+        return instance;
+    }
+
     public String compose(ByteBuffer bytes)
     {
         return getString(bytes);
     }
 
+    public ByteBuffer decompose(String value)
+    {
+        return ByteBufferUtil.bytes(value, Charsets.UTF_8);
+    }
+
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         return BytesType.bytesCompare(o1, o2);
@@ -60,9 +71,9 @@ public class UTF8Type extends AbstractTy
 
     public ByteBuffer fromString(String source)
     {
-        return ByteBufferUtil.bytes(source);
+        return decompose(source);
     }
-    
+
     public void validate(ByteBuffer bytes) throws MarshalException
     {
         if (!UTF8Validator.validate(bytes.slice()))



Mime
View raw message