cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [3/4] git commit: Allow custom types in CLI's assume command
Date Fri, 30 Mar 2012 14:47:40 GMT
Allow custom types in CLI's assume command

patch by xedin; reviewed by slebresne for CASSANDRA-4081


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

Branch: refs/heads/cassandra-1.1.0
Commit: 7326ba88795665d241d2aac9a1386598f35f157e
Parents: b85d44a
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Fri Mar 30 10:33:29 2012 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Fri Mar 30 10:33:29 2012 +0200

----------------------------------------------------------------------
 CHANGES.txt                                      |    1 +
 src/java/org/apache/cassandra/cli/Cli.g          |    4 +-
 src/java/org/apache/cassandra/cli/CliClient.java |   20 +++++++++++-----
 3 files changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7326ba88/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e4d207c..3316e87 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -14,6 +14,7 @@
  * ensure that directory is selected for compaction for user-defined
    tasks and upgradesstables (CASSANDRA-3985)
  * fix NPE on invalid CQL delete command (CASSANDRA-3755)
+ * allow custom types in CLI's assume command (CASSANDRA-4081)
 
 
 1.0.8

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7326ba88/src/java/org/apache/cassandra/cli/Cli.g
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cli/Cli.g b/src/java/org/apache/cassandra/cli/Cli.g
index e7cba6c..742ccf2 100644
--- a/src/java/org/apache/cassandra/cli/Cli.g
+++ b/src/java/org/apache/cassandra/cli/Cli.g
@@ -301,8 +301,8 @@ truncateStatement
     ;
 
 assumeStatement
-    : ASSUME columnFamily assumptionElement=Identifier 'AS' defaultType=Identifier
-        -> ^(NODE_ASSUME columnFamily $assumptionElement $defaultType)
+    : ASSUME columnFamily assumptionElement=Identifier 'AS' entityName
+        -> ^(NODE_ASSUME columnFamily $assumptionElement entityName)
     ;
 
 consistencyLevelStatement

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7326ba88/src/java/org/apache/cassandra/cli/CliClient.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cli/CliClient.java b/src/java/org/apache/cassandra/cli/CliClient.java
index 8e76b89..dfbcb68 100644
--- a/src/java/org/apache/cassandra/cli/CliClient.java
+++ b/src/java/org/apache/cassandra/cli/CliClient.java
@@ -1491,17 +1491,25 @@ public class CliClient
         AbstractType comparator;
 
         // Could be UTF8Type, IntegerType, LexicalUUIDType etc.
-        String defaultType = statement.getChild(2).getText();
+        String defaultType = CliUtils.unescapeSQLString(statement.getChild(2).getText());
 
         try
         {
-            comparator = Function.valueOf(defaultType.toUpperCase()).getValidator();
+            comparator = TypeParser.parse(defaultType);
         }
-        catch (Exception e)
+        catch (ConfigurationException e)
         {
-            String functions = Function.getFunctionNames();
-            sessionState.out.println("Type '" + defaultType + "' was not found. Available:
" + functions);
-            return;
+            try
+            {
+                comparator = Function.valueOf(defaultType.toUpperCase()).getValidator();
+            }
+            catch (Exception ne)
+            {
+                String functions = Function.getFunctionNames();
+                sessionState.out.println("Type '" + defaultType + "' was not found. Available:
" + functions
+                                         + " Or any class which extends o.a.c.db.marshal.AbstractType.");
+                return;
+            }
         }
 
         // making string representation look property e.g. o.a.c.db.marshal.UTF8Type


Mime
View raw message