cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r959485 - /cassandra/trunk/src/java/org/apache/cassandra/db/marshal/UTF8Type.java
Date Thu, 01 Jul 2010 01:32:26 GMT
Author: jbellis
Date: Thu Jul  1 01:32:26 2010
New Revision: 959485

URL: http://svn.apache.org/viewvc?rev=959485&view=rev
Log:
use lexical comparison for UTF8Type.  patch by Nick Bailey; reviewed by jbellis for CASSANDRA-1232

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/db/marshal/UTF8Type.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/marshal/UTF8Type.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/marshal/UTF8Type.java?rev=959485&r1=959484&r2=959485&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/marshal/UTF8Type.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/marshal/UTF8Type.java Thu Jul  1 01:32:26
2010
@@ -20,36 +20,27 @@ package org.apache.cassandra.db.marshal;
  * 
  */
 
+import java.io.IOException;
+import java.nio.charset.CharacterCodingException;
+import java.util.Arrays;
 
-import java.io.UnsupportedEncodingException;
+import org.apache.cassandra.utils.FBUtilities;
 
-public class UTF8Type extends AbstractType
+public class UTF8Type extends BytesType
 {
     public static final UTF8Type instance = new UTF8Type();
 
     UTF8Type() {} // singleton
 
-    public int compare(byte[] o1, byte[] o2)
-    {
-        try
-        {
-            return new String(o1, "UTF-8").compareTo(new String(o2, "UTF-8"));
-        }
-        catch (UnsupportedEncodingException e)
-        {
-            throw new RuntimeException(e);
-        }
-    }
-
     public String getString(byte[] bytes)
     {
         try
         {
-            return new String(bytes, "UTF-8");
+            return FBUtilities.decodeToUTF8(bytes);
         }
-        catch (UnsupportedEncodingException e)
+        catch (CharacterCodingException e)
         {
-            throw new RuntimeException(e);
+            throw new MarshalException("invalid UTF8 bytes " + Arrays.toString(bytes));
         }
     }
 }



Mime
View raw message