cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [2/3] git commit: move ConfigurationException check to Create statement
Date Thu, 26 Jan 2012 17:33:34 GMT
move ConfigurationException check to Create statement


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

Branch: refs/heads/trunk
Commit: 96ecaff517418c63b93688865dbb435b2186372f
Parents: 54d9fbb
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Jan 26 10:29:44 2012 -0600
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Jan 26 11:25:25 2012 -0600

----------------------------------------------------------------------
 .../org/apache/cassandra/config/CFMetaData.java    |   45 ++++++--------
 .../statements/CreateColumnFamilyStatement.java    |    2 +
 .../apache/cassandra/db/marshal/CompositeType.java |   10 +---
 .../cassandra/db/marshal/CompositeTypeTest.java    |    9 +---
 4 files changed, 24 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/96ecaff5/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java
index c5b2633..dc50102 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -85,36 +85,29 @@ public final class CFMetaData
 
     private static CFMetaData schemaCFDefinition(String name, int index, String comment,
AbstractType<?> comp, int nestingLevel)
     {
-        try
-        {
-            AbstractType<?> comparator;
-
-            if (nestingLevel == 1)
-            {
-                comparator = comp;
-            }
-            else
-            {
-                List<AbstractType<?>> composite = new ArrayList<AbstractType<?>>(nestingLevel);
-
-                for (int i = 0; i < nestingLevel; i++)
-                    composite.add(comp);
-
-                comparator = CompositeType.getInstance(composite);
-            }
+        AbstractType<?> comparator;
 
-            return newSystemMetadata(name,
-                                     index,
-                                     comment,
-                                     comparator,
-                                     null)
-                                     .keyValidator(AsciiType.instance)
-                                     .defaultValidator(UTF8Type.instance);
+        if (nestingLevel == 1)
+        {
+            comparator = comp;
         }
-        catch (ConfigurationException e)
+        else
         {
-            throw new RuntimeException(e);
+            List<AbstractType<?>> composite = new ArrayList<AbstractType<?>>(nestingLevel);
+
+            for (int i = 0; i < nestingLevel; i++)
+                composite.add(comp);
+
+            comparator = CompositeType.getInstance(composite);
         }
+
+        return newSystemMetadata(name,
+                                 index,
+                                 comment,
+                                 comparator,
+                                 null)
+                                 .keyValidator(AsciiType.instance)
+                                 .defaultValidator(UTF8Type.instance);
     }
 
     static

http://git-wip-us.apache.org/repos/asf/cassandra/blob/96ecaff5/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
b/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
index 48f4c61..eec47cf 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
@@ -207,6 +207,8 @@ public class CreateColumnFamilyStatement extends SchemaAlteringStatement
                         if (!useCompactStorage)
                             types.add(CFDefinition.definitionType);
 
+                        if (types.isEmpty())
+                            throw new IllegalStateException("Nonsensical empty parameter
list for CompositeType");
                         stmt.comparator = CompositeType.getInstance(types);
                     }
                 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/96ecaff5/src/java/org/apache/cassandra/db/marshal/CompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/CompositeType.java b/src/java/org/apache/cassandra/db/marshal/CompositeType.java
index 27cfea1..c9e866e 100644
--- a/src/java/org/apache/cassandra/db/marshal/CompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/CompositeType.java
@@ -57,15 +57,9 @@ public class CompositeType extends AbstractCompositeType
     // interning instances
     private static final Map<List<AbstractType<?>>, CompositeType> instances
= new HashMap<List<AbstractType<?>>, CompositeType>();
 
-    public static CompositeType getInstance(TypeParser parser) throws ConfigurationException
+    public static synchronized CompositeType getInstance(List<AbstractType<?>>
types)
     {
-        return getInstance(parser.getTypeParameters());
-    }
-
-    public static synchronized CompositeType getInstance(List<AbstractType<?>>
types) throws ConfigurationException
-    {
-        if (types == null || types.isEmpty())
-            throw new ConfigurationException("Nonsensical empty parameter list for CompositeType");
+        assert types != null && !types.isEmpty();
 
         CompositeType ct = instances.get(types);
         if (ct == null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/96ecaff5/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java b/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
index e32943b..80efe00 100644
--- a/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
+++ b/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
@@ -46,14 +46,7 @@ public class CompositeTypeTest extends CleanupHelper
         subComparators.add(BytesType.instance);
         subComparators.add(TimeUUIDType.instance);
         subComparators.add(IntegerType.instance);
-        try
-        {
-            comparator = CompositeType.getInstance(subComparators);
-        }
-        catch (ConfigurationException e)
-        {
-            throw new RuntimeException(e);
-        }
+        comparator = CompositeType.getInstance(subComparators);
 
     }
 


Mime
View raw message