You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2012/12/20 16:12:29 UTC

git commit: Disallow counters in collection

Updated Branches:
  refs/heads/cassandra-1.2.0 cfe51fb4f -> 986893e42


Disallow counters in collection

patch by slebresne; reviewed by jbellis for CASSANDRA-5082


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

Branch: refs/heads/cassandra-1.2.0
Commit: 986893e424677964e7e44baeffdb3ae0f2a914da
Parents: cfe51fb
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Thu Dec 20 16:11:03 2012 +0100
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Thu Dec 20 16:11:03 2012 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |    3 ++
 src/java/org/apache/cassandra/cql3/ParsedType.java |   22 +++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/986893e4/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3afbde4..45b0b5b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,6 @@
+1.2.0
+ * Disallow counters in collections (CASSANDRA-5082)
+
 1.2.0-rc2
  * fix nodetool ownership display with vnodes (CASSANDRA-5065)
  * cqlsh: add DESCRIBE KEYSPACES command (CASSANDRA-5060)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/986893e4/src/java/org/apache/cassandra/cql3/ParsedType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ParsedType.java b/src/java/org/apache/cassandra/cql3/ParsedType.java
index 1bb8a12..d8d6e12 100644
--- a/src/java/org/apache/cassandra/cql3/ParsedType.java
+++ b/src/java/org/apache/cassandra/cql3/ParsedType.java
@@ -25,6 +25,7 @@ import org.apache.cassandra.exceptions.SyntaxException;
 public interface ParsedType
 {
     public boolean isCollection();
+    public boolean isCounter();
     public AbstractType<?> getType();
 
     public enum Native implements ParsedType
@@ -62,6 +63,11 @@ public interface ParsedType
         {
             return type;
         }
+
+        public boolean isCounter()
+        {
+            return this == COUNTER;
+        }
     }
 
     public static class Custom implements ParsedType
@@ -82,6 +88,11 @@ public interface ParsedType
         {
             return type;
         }
+
+        public boolean isCounter()
+        {
+            return false;
+        }
     }
 
     public static class Collection implements ParsedType
@@ -97,6 +108,8 @@ public interface ParsedType
         {
             if (t1.isCollection() || t2.isCollection())
                 throw new InvalidRequestException("map type cannot contain another collection");
+            if (t1.isCounter() || t2.isCounter())
+                throw new InvalidRequestException("counters are not allowed inside a collection");
 
             return new Collection(MapType.getInstance(t1.getType(), t2.getType()));
         }
@@ -105,6 +118,8 @@ public interface ParsedType
         {
             if (t.isCollection())
                 throw new InvalidRequestException("list type cannot contain another collection");
+            if (t.isCounter())
+                throw new InvalidRequestException("counters are not allowed inside a collection");
 
             return new Collection(ListType.getInstance(t.getType()));
         }
@@ -113,6 +128,8 @@ public interface ParsedType
         {
             if (t.isCollection())
                 throw new InvalidRequestException("set type cannot contain another collection");
+            if (t.isCounter())
+                throw new InvalidRequestException("counters are not allowed inside a collection");
 
             return new Collection(SetType.getInstance(t.getType()));
         }
@@ -126,5 +143,10 @@ public interface ParsedType
         {
             return type;
         }
+
+        public boolean isCounter()
+        {
+            return false;
+        }
     }
 }