Merge branch 'cassandra-2.0' 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/5e304eb7 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/5e304eb7 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/5e304eb7 Branch: refs/heads/trunk Commit: 5e304eb78a3e9227260998c335ee0e01ebab07d7 Parents: 1dc43bd 5fa6055 Author: Aleksey Yeschenko <alek...@apache.org> Authored: Tue Jan 7 18:11:26 2014 +0300 Committer: Aleksey Yeschenko <alek...@apache.org> Committed: Tue Jan 7 18:11:26 2014 +0300 ---------------------------------------------------------------------- CHANGES.txt | 3 +- bin/cqlsh | 2 +- doc/cql3/CQL.textile | 9 ++- pylib/cqlshlib/cql3handling.py | 2 +- src/java/org/apache/cassandra/cql3/Cql.g | 9 +-- .../apache/cassandra/cql3/QueryProcessor.java | 2 +- .../cql3/statements/CreateIndexStatement.java | 30 ++++----- .../cql3/statements/IndexPropDefs.java | 70 ++++++++++++++++++++ 8 files changed, 100 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/5e304eb7/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index 11c2814,faf52a4..45a3eb6 --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,30 -1,6 +1,31 @@@ +2.1 + * Introduce AtomicBTreeColumns (CASSANDRA-6271) + * Multithreaded commitlog (CASSANDRA-3578) + * allocate fixed index summary memory pool and resample cold index summaries + to use less memory (CASSANDRA-5519) + * Removed multithreaded compaction (CASSANDRA-6142) + * Parallelize fetching rows for low-cardinality indexes (CASSANDRA-1337) + * change logging from log4j to logback (CASSANDRA-5883) + * switch to LZ4 compression for internode communication (CASSANDRA-5887) + * Stop using Thrift-generated Index* classes internally (CASSANDRA-5971) + * Remove 1.2 network compatibility code (CASSANDRA-5960) + * Remove leveled json manifest migration code (CASSANDRA-5996) + * Remove CFDefinition (CASSANDRA-6253) + * Use AtomicIntegerFieldUpdater in RefCountedMemory (CASSANDRA-6278) + * User-defined types for CQL3 (CASSANDRA-5590) + * Use of o.a.c.metrics in nodetool (CASSANDRA-5871, 6406) + * Batch read from OTC's queue and cleanup (CASSANDRA-1632) + * Secondary index support for collections (CASSANDRA-4511) + * SSTable metadata(Stats.db) format change (CASSANDRA-6356) + * Push composites support in the storage engine + (CASSANDRA-5417, CASSANDRA-6520) + * Add snapshot space used to cfstats (CASSANDRA-6231) + * Add cardinality estimator for key count estimation (CASSANDRA-5906) + + 2.0.5 - * Delete unfinished compaction incrementally (CASSANDRA-6086) + * Delete unfinished compaction incrementally (CASSANDRA-6086) + * Allow specifying custom secondary index options in CQL3 (CASSANDRA-6480) Merged from 1.2: * fsync compression metadata (CASSANDRA-6531) * Validate CF existence on execution for prepared statement (CASSANDRA-6535) http://git-wip-us.apache.org/repos/asf/cassandra/blob/5e304eb7/src/java/org/apache/cassandra/cql3/Cql.g ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/5e304eb7/src/java/org/apache/cassandra/cql3/QueryProcessor.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/5e304eb7/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java index e0e2693,3ef6f5a..56b465e --- a/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java @@@ -18,19 -18,14 +18,17 @@@ package org.apache.cassandra.cql3.statements; import java.util.Collections; +import java.util.Map; ++import com.google.common.collect.ImmutableMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.cassandra.auth.Permission; import org.apache.cassandra.config.CFMetaData; import org.apache.cassandra.config.ColumnDefinition; +import org.apache.cassandra.config.IndexType; import org.apache.cassandra.config.Schema; - import org.apache.cassandra.db.index.SecondaryIndex; import org.apache.cassandra.exceptions.*; import org.apache.cassandra.cql3.*; import org.apache.cassandra.service.ClientState; @@@ -83,17 -81,16 +83,13 @@@ public class CreateIndexStatement exten throw new InvalidRequestException("Index already exists"); } - if (isCustom && indexClass == null) - throw new InvalidRequestException("CUSTOM index requires specifiying the index class"); - - if (!isCustom && indexClass != null) - throw new InvalidRequestException("Cannot specify index class for a non-CUSTOM index"); + properties.validate(); // 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 (cfm.comparator.isDense() && cd.kind != ColumnDefinition.Kind.REGULAR) + throw new InvalidRequestException(String.format("Secondary index on %s column %s is not yet supported for compact table", cd.kind, columnName)); - if (cd.getValidator().isCollection() && !properties.isCustom) - throw new InvalidRequestException("Indexes on collections are no yet supported"); - - if (cd.type == ColumnDefinition.Type.PARTITION_KEY && cd.componentIndex == null) + if (cd.kind == ColumnDefinition.Kind.PARTITION_KEY && cd.isOnAllComponents()) throw new InvalidRequestException(String.format("Cannot add secondary index to already primarily indexed column %s", columnName)); } @@@ -106,24 -103,12 +102,24 @@@ if (cd.getIndexType() != null && ifNotExists) return; - if (isCustom) + if (properties.isCustom) + { - cd.setIndexType(IndexType.CUSTOM, Collections.singletonMap(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME, indexClass)); + cd.setIndexType(IndexType.CUSTOM, properties.getOptions()); - else if (cfm.getCfDef().isComposite) - cd.setIndexType(IndexType.COMPOSITES, Collections.<String, String>emptyMap()); + } + else if (cfm.comparator.isCompound()) + { + Map<String, String> options = Collections.emptyMap(); + // For now, we only allow indexing values for collections, but we could later allow + // to also index map keys, so we record that this is the values we index to make our + // lives easier then. + if (cd.type.isCollection()) + options = ImmutableMap.of("index_values", ""); - cd.setIndexType(IndexType.COMPOSITES, Collections.<String, String>emptyMap()); ++ cd.setIndexType(IndexType.COMPOSITES, options); + } else + { cd.setIndexType(IndexType.KEYS, Collections.<String, String>emptyMap()); + } cd.setIndexName(indexName); cfm.addDefaultIndexNames();