cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject svn commit: r1209514 - in /cassandra/branches/cassandra-1.0: CHANGES.txt src/java/org/apache/cassandra/cli/CliClient.java test/unit/org/apache/cassandra/cli/CliTest.java
Date Fri, 02 Dec 2011 14:39:29 GMT
Author: xedin
Date: Fri Dec  2 14:39:28 2011
New Revision: 1209514

URL: http://svn.apache.org/viewvc?rev=1209514&view=rev
Log:
fix default value validation usage in CLI SET command
patch by Pavel Yaskevich; reviewed by Jonathan Ellis for CASSANDRA-3553

Modified:
    cassandra/branches/cassandra-1.0/CHANGES.txt
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cli/CliClient.java
    cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/cli/CliTest.java

Modified: cassandra/branches/cassandra-1.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/CHANGES.txt?rev=1209514&r1=1209513&r2=1209514&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-1.0/CHANGES.txt Fri Dec  2 14:39:28 2011
@@ -8,7 +8,7 @@
  * always remove endpoints from delevery queue in HH (CASSANDRA-3546)
  * fix race between cf flush and its 2ndary indexes flush (CASSANDRA-3547)
  * fix potential race in AES when a repair fails (CASSANDRA-3548)
-
+ * fix default value validation usage in CLI SET command (CASSANDRA-3553)
 
 1.0.5
  * revert CASSANDRA-3407 (see CASSANDRA-3540)

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cli/CliClient.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cli/CliClient.java?rev=1209514&r1=1209513&r2=1209514&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cli/CliClient.java (original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/cli/CliClient.java Fri
Dec  2 14:39:28 2011
@@ -2497,7 +2497,8 @@ public class CliClient
     private ByteBuffer columnValueAsBytes(ByteBuffer columnName, String columnFamilyName,
String columnValue)
     {
         CfDef columnFamilyDef = getCfDef(columnFamilyName);
-        
+        AbstractType defaultValidator = getFormatType(columnFamilyDef.default_validation_class);
+
         for (ColumnDef columnDefinition : columnFamilyDef.getColumn_metadata())
         {
             byte[] currentColumnName = columnDefinition.getName();
@@ -2516,8 +2517,7 @@ public class CliClient
             }
         }
 
-        // if no validation were set returning simple .getBytes()
-        return ByteBufferUtil.bytes(columnValue);
+        return defaultValidator.fromString(columnValue);
     }
 
     /**

Modified: cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/cli/CliTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/cli/CliTest.java?rev=1209514&r1=1209513&r2=1209514&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/cli/CliTest.java (original)
+++ cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/cli/CliTest.java Fri Dec
 2 14:39:28 2011
@@ -43,7 +43,8 @@ public class CliTest extends CleanupHelp
                                                                                "{ column_name:world2,
validation_class:LongType, index_type:KEYS, index_name:LongIdxName}, " +
                                                                                "{ column_name:617070,
validation_class:UTF8Type, index_type:KEYS }, " +
                                                                                "{ column_name:28292,
validation_class:UTF8Type, index_type:CUSTOM, index_options:{class_name:'org.apache.cassandra.db.index.keys.KeysIndex',
foo:bar}}," +
-                                                                               "{ column_name:'-617071',
validation_class:UTF8Type, index_type:KEYS }];",
+                                                                               "{ column_name:'-617071',
validation_class:UTF8Type, index_type:KEYS }," +
+                                                                               "{ column_name:time_spent_uuid,
validation_class:TimeUUIDType}] and default_validation_class=UTF8Type;",
         "assume 123 keys as utf8;",
         "set 123[hello][world] = 123848374878933948398384;",
         "set 123[hello][test_quote] = 'value\\'';",
@@ -60,7 +61,6 @@ public class CliTest extends CleanupHelp
         "get 123[hello][test_quote];",
         "get 123['k\\'ey'][VALUE]",
         "set 123[hello][-31337] = -23876;",
-        "set 123[hello][-31337] = long(-23876);",
         "set 123[hello][world2] = 15;",
         "get 123 where world2 = long(15);",
         "get 123 where world2 = long(15);",
@@ -68,7 +68,7 @@ public class CliTest extends CleanupHelp
         "del 123[utf8('hello')][utf8('world')];",
         "del 123[hello][world2];",
         "set 123['hello'][time_spent_uuid] = timeuuid(a8098c1a-f86e-11da-bd1a-00112444be1e);",
-        "create column family CF2 with comparator=IntegerType;",
+        "create column family CF2 with comparator=IntegerType and default_validation_class=AsciiType;",
         "assume CF2 keys as utf8;",
         "set CF2['key'][98349387493847748398334] = 'some text';",
         "get CF2['key'][98349387493847748398334];",
@@ -160,7 +160,7 @@ public class CliTest extends CleanupHelp
         "drop keyspace tesTIN;",
         "update column family 123 with comparator=UTF8Type and column_metadata=[];",
         "drop column family 123;",
-        "create column family myCF with column_type='Super' and comparator='UTF8Type' AND
subcomparator='UTF8Type';",
+        "create column family myCF with column_type='Super' and comparator='UTF8Type' AND
subcomparator='UTF8Type' AND default_validation_class=AsciiType;",
         "assume myCF keys as utf8;",
         "create column family Countries with comparator=UTF8Type and column_metadata=[ {column_name:
name, validation_class: UTF8Type} ];",
         "set Countries[1][name] = USA;",



Mime
View raw message