cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [2/2] git commit: Merge branch 'cassandra-2.0' into cassandra-2.1.0
Date Thu, 04 Sep 2014 19:04:49 GMT
Merge branch 'cassandra-2.0' into cassandra-2.1.0

Conflicts:
	src/java/org/apache/cassandra/config/CFMetaData.java
	src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java


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

Branch: refs/heads/cassandra-2.1.0
Commit: 37c6b2f2260fa7447d3fea9f0f3c2b4102028e91
Parents: 1908ae3 77b036a
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Thu Sep 4 15:04:37 2014 -0400
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Thu Sep 4 15:04:37 2014 -0400

----------------------------------------------------------------------
 .../org/apache/cassandra/config/CFMetaData.java | 21 ++++++++++++--------
 .../cql3/statements/CreateTableStatement.java   |  2 +-
 2 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/37c6b2f2/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/config/CFMetaData.java
index 7466b56,e726957..c7b48e3
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@@ -483,26 -449,27 +483,26 @@@ public final class CFMetaDat
      public CFMetaData memtableFlushPeriod(int prop) {memtableFlushPeriod = prop; return
this;}
      public CFMetaData defaultTimeToLive(int prop) {defaultTimeToLive = prop; return this;}
      public CFMetaData speculativeRetry(SpeculativeRetry prop) {speculativeRetry = prop;
return this;}
 -    public CFMetaData populateIoCacheOnFlush(boolean prop) {populateIoCacheOnFlush = prop;
return this;}
 -    public CFMetaData droppedColumns(Map<ByteBuffer, Long> cols) {droppedColumns =
cols; return this;}
 +    public CFMetaData droppedColumns(Map<ColumnIdentifier, Long> cols) {droppedColumns
= cols; return this;}
      public CFMetaData triggers(Map<String, TriggerDefinition> prop) {triggers = prop;
return this;}
-     public CFMetaData setDense(Boolean prop) {isDense = prop; return this;}
+     public CFMetaData isDense(Boolean prop) {isDense = prop; return this;}
  
 -    public CFMetaData(String keyspace, String name, ColumnFamilyType type, AbstractType<?>
comp, AbstractType<?> subcc)
 -    {
 -        this(keyspace, name, type, makeComparator(type, comp, subcc));
 -    }
 -
 -    public CFMetaData(String keyspace, String name, ColumnFamilyType type, AbstractType<?>
comp)
 +    /**
 +     * Create new ColumnFamily metadata with generated random ID.
 +     * When loading from existing schema, use CFMetaData
 +     *
 +     * @param keyspace keyspace name
 +     * @param name column family name
 +     * @param comp default comparator
 +     */
 +    public CFMetaData(String keyspace, String name, ColumnFamilyType type, CellNameType
comp)
      {
 -        this(keyspace, name, type, comp, getId(keyspace, name));
 +        this(keyspace, name, type, comp, UUIDGen.getTimeUUID());
      }
  
 -    @VisibleForTesting
 -    CFMetaData(String keyspace, String name, ColumnFamilyType type, AbstractType<?>
comp,  UUID id)
 +    private CFMetaData(String keyspace, String name, ColumnFamilyType type, CellNameType
comp, UUID id)
      {
 -        // (subcc may be null for non-supercolumns)
 -        // (comp may also be null for custom indexes, which is kind of broken if you ask
me)
 -
 +        cfId = id;
          ksName = keyspace;
          cfName = name;
          cfType = type;
@@@ -657,13 -599,13 +657,13 @@@
                        .bloomFilterFpChance(oldCFMD.bloomFilterFpChance)
                        .caching(oldCFMD.caching)
                        .defaultTimeToLive(oldCFMD.defaultTimeToLive)
 -                      .indexInterval(oldCFMD.indexInterval)
 +                      .minIndexInterval(oldCFMD.minIndexInterval)
 +                      .maxIndexInterval(oldCFMD.maxIndexInterval)
                        .speculativeRetry(oldCFMD.speculativeRetry)
                        .memtableFlushPeriod(oldCFMD.memtableFlushPeriod)
 -                      .populateIoCacheOnFlush(oldCFMD.populateIoCacheOnFlush)
                        .droppedColumns(new HashMap<>(oldCFMD.droppedColumns))
                        .triggers(new HashMap<>(oldCFMD.triggers))
-                       .setDense(oldCFMD.isDense)
+                       .isDense(oldCFMD.isDense)
                        .rebuild();
      }
  
@@@ -880,47 -786,55 +880,52 @@@
          return droppedColumns;
      }
  
+     public Boolean getIsDense()
+     {
+         return isDense;
+     }
+ 
 -    public boolean equals(Object obj)
 +    @Override
 +    public boolean equals(Object o)
      {
 -        if (obj == this)
 -        {
 +        if (this == o)
              return true;
 -        }
 -        else if (obj == null || obj.getClass() != getClass())
 -        {
 +
 +        if (!(o instanceof CFMetaData))
              return false;
 -        }
  
 -        CFMetaData rhs = (CFMetaData) obj;
 -        return new EqualsBuilder()
 -            .append(ksName, rhs.ksName)
 -            .append(cfName, rhs.cfName)
 -            .append(cfType, rhs.cfType)
 -            .append(comparator, rhs.comparator)
 -            .append(comment, rhs.comment)
 -            .append(readRepairChance, rhs.readRepairChance)
 -            .append(dcLocalReadRepairChance, rhs.dcLocalReadRepairChance)
 -            .append(replicateOnWrite, rhs.replicateOnWrite)
 -            .append(gcGraceSeconds, rhs.gcGraceSeconds)
 -            .append(defaultValidator, rhs.defaultValidator)
 -            .append(keyValidator, rhs.keyValidator)
 -            .append(minCompactionThreshold, rhs.minCompactionThreshold)
 -            .append(maxCompactionThreshold, rhs.maxCompactionThreshold)
 -            .append(cfId, rhs.cfId)
 -            .append(column_metadata, rhs.column_metadata)
 -            .append(compactionStrategyClass, rhs.compactionStrategyClass)
 -            .append(compactionStrategyOptions, rhs.compactionStrategyOptions)
 -            .append(compressionParameters, rhs.compressionParameters)
 -            .append(bloomFilterFpChance, rhs.bloomFilterFpChance)
 -            .append(memtableFlushPeriod, rhs.memtableFlushPeriod)
 -            .append(caching, rhs.caching)
 -            .append(defaultTimeToLive, rhs.defaultTimeToLive)
 -            .append(indexInterval, rhs.indexInterval)
 -            .append(speculativeRetry, rhs.speculativeRetry)
 -            .append(populateIoCacheOnFlush, rhs.populateIoCacheOnFlush)
 -            .append(droppedColumns, rhs.droppedColumns)
 -            .append(triggers, rhs.triggers)
 -            .append(isDense, rhs.isDense)
 -            .isEquals();
 +        CFMetaData other = (CFMetaData) o;
 +
 +        return Objects.equal(cfId, other.cfId)
 +            && Objects.equal(ksName, other.ksName)
 +            && Objects.equal(cfName, other.cfName)
 +            && Objects.equal(cfType, other.cfType)
 +            && Objects.equal(comparator, other.comparator)
 +            && Objects.equal(comment, other.comment)
 +            && Objects.equal(readRepairChance, other.readRepairChance)
 +            && Objects.equal(dcLocalReadRepairChance, other.dcLocalReadRepairChance)
 +            && Objects.equal(gcGraceSeconds, other.gcGraceSeconds)
 +            && Objects.equal(defaultValidator, other.defaultValidator)
 +            && Objects.equal(keyValidator, other.keyValidator)
 +            && Objects.equal(minCompactionThreshold, other.minCompactionThreshold)
 +            && Objects.equal(maxCompactionThreshold, other.maxCompactionThreshold)
 +            && Objects.equal(columnMetadata, other.columnMetadata)
 +            && Objects.equal(compactionStrategyClass, other.compactionStrategyClass)
 +            && Objects.equal(compactionStrategyOptions, other.compactionStrategyOptions)
 +            && Objects.equal(compressionParameters, other.compressionParameters)
 +            && Objects.equal(bloomFilterFpChance, other.bloomFilterFpChance)
 +            && Objects.equal(memtableFlushPeriod, other.memtableFlushPeriod)
 +            && Objects.equal(caching, other.caching)
 +            && Objects.equal(defaultTimeToLive, other.defaultTimeToLive)
 +            && Objects.equal(minIndexInterval, other.minIndexInterval)
 +            && Objects.equal(maxIndexInterval, other.maxIndexInterval)
 +            && Objects.equal(speculativeRetry, other.speculativeRetry)
 +            && Objects.equal(droppedColumns, other.droppedColumns)
 +            && Objects.equal(triggers, other.triggers)
 +            && Objects.equal(isDense, other.isDense);
      }
  
 +    @Override
      public int hashCode()
      {
          return new HashCodeBuilder(29, 1597)
@@@ -1022,57 -971,17 +1027,57 @@@
  
          try
          {
 -            CFMetaData newCFMD = new CFMetaData(cf_def.keyspace,
 -                                                cf_def.name,
 -                                                cfType,
 -                                                TypeParser.parse(cf_def.comparator_type),
 -                                                cf_def.subcomparator_type == null ? null
: TypeParser.parse(cf_def.subcomparator_type));
 -
 -            if (cf_def.isSetGc_grace_seconds()) { newCFMD.gcGraceSeconds(cf_def.gc_grace_seconds);
}
 -            if (cf_def.isSetMin_compaction_threshold()) { newCFMD.minCompactionThreshold(cf_def.min_compaction_threshold);
}
 -            if (cf_def.isSetMax_compaction_threshold()) { newCFMD.maxCompactionThreshold(cf_def.max_compaction_threshold);
}
 +            AbstractType<?> rawComparator = TypeParser.parse(cf_def.comparator_type);
 +            AbstractType<?> subComparator = cfType == ColumnFamilyType.Standard
 +                                          ? null
 +                                          : cf_def.subcomparator_type == null ? BytesType.instance
: TypeParser.parse(cf_def.subcomparator_type);
 +
 +            AbstractType<?> fullRawComparator = makeRawAbstractType(rawComparator,
subComparator);
 +
 +            AbstractType<?> keyValidator = cf_def.isSetKey_validation_class() ? TypeParser.parse(cf_def.key_validation_class)
: null;
 +
 +            // Convert the REGULAR definitions from the input CfDef
 +            List<ColumnDefinition> defs = ColumnDefinition.fromThrift(cf_def.keyspace,
cf_def.name, rawComparator, subComparator, cf_def.column_metadata);
 +
 +            // Add the keyAlias if there is one, since that's on CQL metadata that thrift
can actually change (for
 +            // historical reasons)
 +            boolean hasKeyAlias = cf_def.isSetKey_alias() && keyValidator != null
&& !(keyValidator instanceof CompositeType);
 +            if (hasKeyAlias)
 +                defs.add(ColumnDefinition.partitionKeyDef(cf_def.keyspace, cf_def.name,
cf_def.key_alias, keyValidator, null));
 +
 +            // Now add any CQL metadata that we want to copy, skipping the keyAlias if there
was one
 +            for (ColumnDefinition def : previousCQLMetadata)
 +            {
 +                // isPartOfCellName basically means 'is not just a CQL metadata'
 +                if (def.isPartOfCellName())
 +                    continue;
 +
 +                if (def.kind == ColumnDefinition.Kind.PARTITION_KEY && hasKeyAlias)
 +                    continue;
 +
 +                defs.add(def);
 +            }
 +
-             CellNameType comparator = CellNames.fromAbstractType(fullRawComparator, isDense(fullRawComparator,
defs));
++            CellNameType comparator = CellNames.fromAbstractType(fullRawComparator, calculateIsDense(fullRawComparator,
defs));
 +
 +            UUID cfId = Schema.instance.getId(cf_def.keyspace, cf_def.name);
 +            if (cfId == null)
 +                cfId = UUIDGen.getTimeUUID();
 +
 +            CFMetaData newCFMD = new CFMetaData(cf_def.keyspace, cf_def.name, cfType, comparator,
cfId);
 +
 +            newCFMD.addAllColumnDefinitions(defs);
 +
 +            if (keyValidator != null)
 +                newCFMD.keyValidator(keyValidator);
 +            if (cf_def.isSetGc_grace_seconds())
 +                newCFMD.gcGraceSeconds(cf_def.gc_grace_seconds);
 +            if (cf_def.isSetMin_compaction_threshold())
 +                newCFMD.minCompactionThreshold(cf_def.min_compaction_threshold);
 +            if (cf_def.isSetMax_compaction_threshold())
 +                newCFMD.maxCompactionThreshold(cf_def.max_compaction_threshold);
              if (cf_def.isSetCompaction_strategy())
 -                newCFMD.compactionStrategyClass = createCompactionStrategy(cf_def.compaction_strategy);
 +                newCFMD.compactionStrategyClass(createCompactionStrategy(cf_def.compaction_strategy));
              if (cf_def.isSetCompaction_strategy_options())
                  newCFMD.compactionStrategyOptions(new HashMap<>(cf_def.compaction_strategy_options));
              if (cf_def.isSetBloom_filter_fp_chance())
@@@ -1738,34 -1673,11 +1743,34 @@@
      {
          try
          {
 -            CFMetaData cfm = new CFMetaData(result.getString("keyspace_name"),
 -                                            result.getString("columnfamily_name"),
 -                                            ColumnFamilyType.valueOf(result.getString("type")),
 -                                            TypeParser.parse(result.getString("comparator")),
 -                                            result.has("subcomparator") ? TypeParser.parse(result.getString("subcomparator"))
: null);
 +            String ksName = result.getString("keyspace_name");
 +            String cfName = result.getString("columnfamily_name");
 +
 +            AbstractType<?> rawComparator = TypeParser.parse(result.getString("comparator"));
 +            AbstractType<?> subComparator = result.has("subcomparator") ? TypeParser.parse(result.getString("subcomparator"))
: null;
 +            ColumnFamilyType cfType = ColumnFamilyType.valueOf(result.getString("type"));
 +
 +            AbstractType<?> fullRawComparator = makeRawAbstractType(rawComparator,
subComparator);
 +
 +            List<ColumnDefinition> columnDefs = ColumnDefinition.fromSchema(serializedColumnDefinitions,
 +                                                                            ksName,
 +                                                                            cfName,
 +                                                                            fullRawComparator,
 +                                                                            cfType == ColumnFamilyType.Super);
 +
 +            boolean isDense = result.has("is_dense")
 +                            ? result.getBoolean("is_dense")
-                             : isDense(fullRawComparator, columnDefs);
++                            : calculateIsDense(fullRawComparator, columnDefs);
 +
 +            CellNameType comparator = CellNames.fromAbstractType(fullRawComparator, isDense);
 +
 +            // if we are upgrading, we use id generated from names initially
 +            UUID cfId = result.has("cf_id")
 +                      ? result.getUUID("cf_id")
 +                      : generateLegacyCfId(ksName, cfName);
 +
 +            CFMetaData cfm = new CFMetaData(ksName, cfName, cfType, comparator, cfId);
-             cfm.setDense(isDense);
++            cfm.isDense(isDense);
  
              cfm.readRepairChance(result.getDouble("read_repair_chance"));
              cfm.dcLocalReadRepairChance(result.getDouble("local_read_repair_chance"));
@@@ -2021,27 -1948,47 +2026,27 @@@
  
      public CFMetaData rebuild()
      {
 -        /*
 -         * TODO: There is definitively some repetition between the CQL3  metadata stored
in this
 -         * object (partitionKeyColumns, ...) and the one stored in CFDefinition.
 -         * Ultimately, we should probably merge both. However, there is enough details to
fix that
 -         * it's worth doing that in a separate issue.
 -         */
 -        rebuildCQL3Metadata();
 -        cqlCfDef = new CFDefinition(this);
 -        return this;
 -    }
 -
 -    public CFDefinition getCfDef()
 -    {
 -        assert cqlCfDef != null;
 -        return cqlCfDef;
 -    }
 +        if (isDense == null)
-             setDense(isDense(comparator.asAbstractType(), allColumns()));
++            isDense(calculateIsDense(comparator.asAbstractType(), allColumns()));
  
 -    private void rebuildCQL3Metadata()
 -    {
          List<ColumnDefinition> pkCols = nullInitializedList(keyValidator.componentsCount());
 -        if (isDense == null)
 -            isDense(calculateIsDense(comparator, column_metadata.values()));
 -        int nbCkCols = isDense
 -                     ? comparator.componentsCount()
 -                     : comparator.componentsCount() - (hasCollection() ? 2 : 1);
 -        List<ColumnDefinition> ckCols = nullInitializedList(nbCkCols);
 -        Set<ColumnDefinition> regCols = new HashSet<ColumnDefinition>();
 -        Set<ColumnDefinition> statCols = new HashSet<ColumnDefinition>();
 +        List<ColumnDefinition> ckCols = nullInitializedList(comparator.clusteringPrefixSize());
 +        // We keep things sorted to get consistent/predictable order in select queries
 +        SortedSet<ColumnDefinition> regCols = new TreeSet<>(regularColumnComparator);
 +        SortedSet<ColumnDefinition> statCols = new TreeSet<>(regularColumnComparator);
          ColumnDefinition compactCol = null;
  
 -        for (ColumnDefinition def : column_metadata.values())
 +        for (ColumnDefinition def : allColumns())
          {
 -            switch (def.type)
 +            switch (def.kind)
              {
                  case PARTITION_KEY:
 -                    assert !(def.componentIndex == null && keyValidator instanceof
CompositeType);
 -                    pkCols.set(def.componentIndex == null ? 0 : def.componentIndex, def);
 +                    assert !(def.isOnAllComponents() && keyValidator instanceof
CompositeType);
 +                    pkCols.set(def.position(), def);
                      break;
 -                case CLUSTERING_KEY:
 -                    assert !(def.componentIndex == null && comparator instanceof
CompositeType);
 -                    ckCols.set(def.componentIndex == null ? 0 : def.componentIndex, def);
 +                case CLUSTERING_COLUMN:
 +                    assert !(def.isOnAllComponents() && comparator.isCompound());
 +                    ckCols.set(def.position(), def);
                      break;
                  case REGULAR:
                      regCols.add(def);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37c6b2f2/src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java
index 47f05bb,efaf36d..f7d0739
--- a/src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java
@@@ -147,13 -157,13 +147,13 @@@ public class CreateTableStatement exten
      {
          cfmd.defaultValidator(defaultValidator)
              .keyValidator(keyValidator)
 -            .columnMetadata(getColumns())
 +            .addAllColumnDefinitions(getColumns(cfmd))
-             .setDense(isDense);
+             .isDense(isDense);
  
 -        cfmd.addColumnMetadataFromAliases(keyAliases, keyValidator, ColumnDefinition.Type.PARTITION_KEY);
 -        cfmd.addColumnMetadataFromAliases(columnAliases, comparator, ColumnDefinition.Type.CLUSTERING_KEY);
 +        cfmd.addColumnMetadataFromAliases(keyAliases, keyValidator, ColumnDefinition.Kind.PARTITION_KEY);
 +        cfmd.addColumnMetadataFromAliases(columnAliases, comparator.asAbstractType(), ColumnDefinition.Kind.CLUSTERING_COLUMN);
          if (valueAlias != null)
 -            cfmd.addColumnMetadataFromAliases(Collections.<ByteBuffer>singletonList(valueAlias),
defaultValidator, ColumnDefinition.Type.COMPACT_VALUE);
 +            cfmd.addColumnMetadataFromAliases(Collections.<ByteBuffer>singletonList(valueAlias),
defaultValidator, ColumnDefinition.Kind.COMPACT_VALUE);
  
          properties.applyToCFMetadata(cfmd);
      }


Mime
View raw message