You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2013/06/05 16:30:38 UTC

[1/2] git commit: Allow creating CUSTOM indexes on collections

Updated Branches:
  refs/heads/trunk 523e68376 -> 4b9f1e2ba


Allow creating CUSTOM indexes on collections

patch by Ben Coverston; reviewed by Aleksey Yeschenko for
CASSANDRA-5615


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

Branch: refs/heads/trunk
Commit: ca3c75ecb22fa13e2f58129df83073800ff451ef
Parents: 1f48695
Author: Aleksey Yeschenko <al...@apache.org>
Authored: Wed Jun 5 17:22:04 2013 +0300
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Wed Jun 5 17:22:04 2013 +0300

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../cql3/statements/CreateIndexStatement.java      |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ca3c75ec/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 09e9119..b569b4a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -17,6 +17,7 @@
  * fix SnitchProperties logging context (CASSANDRA-5602)
  * Expose whether jna is enabled and memory is locked via JMX (CASSANDRA-5508)
  * cqlsh: fix COPY FROM with ReversedType (CASSANDRA-5610)
+ * Allow creating CUSTOM indexes on collections (CASSANDRA-5615)
 Merged from 1.1:
  * Remove buggy thrift max message length option (CASSANDRA-5529)
  * Fix NPE in Pig's widerow mode (CASSANDRA-5488)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ca3c75ec/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
index b371c11..549fab8 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
@@ -85,7 +85,7 @@ public class CreateIndexStatement extends SchemaAlteringStatement
                 if (cd.getIndexType() != null)
                     throw new InvalidRequestException("Index already exists");
 
-                if (cd.getValidator().isCollection())
+                if (cd.getValidator().isCollection() && !isCustom)
                     throw new InvalidRequestException("Indexes on collections are no yet supported");
 
                 props.validate(isCustom);


[2/2] git commit: Merge branch 'cassandra-1.2' into trunk

Posted by al...@apache.org.
Merge branch 'cassandra-1.2' into trunk

Conflicts:
	src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java


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

Branch: refs/heads/trunk
Commit: 4b9f1e2bafda044c35710fb9272ff89bca981651
Parents: 523e683 ca3c75e
Author: Aleksey Yeschenko <al...@apache.org>
Authored: Wed Jun 5 17:30:27 2013 +0300
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Wed Jun 5 17:30:27 2013 +0300

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../cql3/statements/CreateIndexStatement.java      |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4b9f1e2b/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4b9f1e2b/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
index 0447bc5,549fab8..4b61ab3
--- a/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
@@@ -62,25 -67,32 +62,25 @@@ public class CreateIndexStatement exten
      public void validate(ClientState state) throws RequestValidationException
      {
          CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
 -        CFDefinition.Name name = cfm.getCfDef().get(columnName);
 +        ColumnDefinition cd = cfm.getColumnDefinition(columnName.key);
  
 -        if (name == null)
 +        if (cd == null)
              throw new InvalidRequestException("No column definition found for column " + columnName);
  
 -        switch (name.kind)
 -        {
 -            case KEY_ALIAS:
 -            case COLUMN_ALIAS:
 -                throw new InvalidRequestException(String.format("Cannot create index on PRIMARY KEY part %s", columnName));
 -            case VALUE_ALIAS:
 -                throw new InvalidRequestException(String.format("Cannot create index on column %s of compact CF", columnName));
 -            case COLUMN_METADATA:
 -                ColumnDefinition cd = cfm.getColumnDefinition(columnName.key);
 -
 -                if (cd.getIndexType() != null)
 -                    throw new InvalidRequestException("Index already exists");
 -
 -                if (cd.getValidator().isCollection() && !isCustom)
 -                    throw new InvalidRequestException("Indexes on collections are no yet supported");
 -
 -                props.validate(isCustom);
 -                break;
 -            default:
 -                throw new AssertionError();
 -        }
 +        if (cd.getIndexType() != null)
 +            throw new InvalidRequestException("Index already exists");
 +
 +        // TODO: we could lift that limitation
 +        if (cfm.getCfDef().isCompact && cd.type != ColumnDefinition.Type.REGULAR)
 +            throw new InvalidRequestException(String.format("Secondary index on %s column %s is not yet supported for compact table", cd.type, columnName));
 +
-         if (cd.getValidator().isCollection())
++        if (cd.getValidator().isCollection() && !isCustom)
 +            throw new InvalidRequestException("Indexes on collections are no yet supported");
 +
 +        if (cd.type == ColumnDefinition.Type.PARTITION_KEY && (cd.componentIndex == null || cd.componentIndex == 0))
 +            throw new InvalidRequestException(String.format("Cannot add secondary index to already primarily indexed column %s", columnName));
 +
 +        props.validate(isCustom);
      }
  
      public void announceMigration() throws InvalidRequestException, ConfigurationException