cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [3/3] git commit: Merge branch 'cassandra-2.0' into cassandra-2.1
Date Wed, 30 Apr 2014 09:35:59 GMT
Merge branch 'cassandra-2.0' into cassandra-2.1

Conflicts:
	CHANGES.txt
	src/java/org/apache/cassandra/config/CFMetaData.java
	test/unit/org/apache/cassandra/config/CFMetaDataTest.java


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

Branch: refs/heads/cassandra-2.1
Commit: 2269adba6c28e24f60883700f657d36fff7b9d3f
Parents: 6b5b7f5 b433722
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Apr 30 11:35:15 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Apr 30 11:35:15 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/config/CFMetaData.java | 45 +++++++++++++++++---
 .../cassandra/thrift/CassandraServer.java       |  3 +-
 .../unit/org/apache/cassandra/SchemaLoader.java | 16 ++++++-
 .../apache/cassandra/config/CFMetaDataTest.java |  5 ++-
 5 files changed, 60 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2269adba/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index b60feb8,e25e71f..64e5afb
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -111,15 -81,7 +111,16 @@@ Merged from 2.0
     (CASSANDRA-6906)
   * Fix SSTable not released if stream session fails (CASSANDRA-6818)
   * Avoid build failure due to ANTLR timeout (CASSANDRA-6991)
 + * Queries on compact tables can return more rows that requested (CASSANDRA-7052)
 + * USING TIMESTAMP for batches does not work (CASSANDRA-7053)
 + * Fix performance regression from CASSANDRA-5614 (CASSANDRA-6949)
 + * Ensure that batchlog and hint timeouts do not produce hints (CASSANDRA-7058)
 + * Merge groupable mutations in TriggerExecutor#execute() (CASSANDRA-7047)
 + * Plug holes in resource release when wiring up StreamSession (CASSANDRA-7073)
 + * Re-add parameter columns to tracing session (CASSANDRA-6942)
++ * Preserves CQL metadata when updating table from thrift (CASSANDRA-6831)
  Merged from 1.2:
 + * Fix nodetool display with vnodes (CASSANDRA-7082)
   * Add UNLOGGED, COUNTER options to BATCH documentation (CASSANDRA-6816)
   * add extra SSL cipher suites (CASSANDRA-6613)
   * fix nodetool getsstables for blob PK (CASSANDRA-6803)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2269adba/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/config/CFMetaData.java
index b4b3fbe,9ca41ac..2e531e8
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@@ -1001,6 -895,44 +1001,44 @@@ public final class CFMetaDat
  
      public static CFMetaData fromThrift(org.apache.cassandra.thrift.CfDef cf_def) throws
InvalidRequestException, ConfigurationException
      {
+         CFMetaData cfm = internalFromThrift(cf_def);
+ 
+         if (cf_def.isSetKey_alias() && !(cfm.keyValidator instanceof CompositeType))
 -            cfm.column_metadata.put(cf_def.key_alias, ColumnDefinition.partitionKeyDef(cf_def.key_alias,
cfm.keyValidator, null));
++            cfm.addOrReplaceColumnDefinition(ColumnDefinition.partitionKeyDef(cfm, cf_def.key_alias,
cfm.keyValidator, null));
+ 
+         return cfm.rebuild();
+     }
+ 
+     public static CFMetaData fromThriftForUpdate(org.apache.cassandra.thrift.CfDef cf_def,
CFMetaData toUpdate) throws InvalidRequestException, ConfigurationException
+     {
+         CFMetaData cfm = internalFromThrift(cf_def);
+ 
+         // Thrift update can't have CQL metadata, and so we'll copy the ones of the updated
metadata (to make
+         // sure we don't override anything existing -- see #6831). One exception (for historical
reasons) is
+         // the partition key column name however, which can be provided through thrift.
If it is, make sure
+         // we use the one of the update.
+         boolean hasKeyAlias = cf_def.isSetKey_alias() && !(cfm.keyValidator instanceof
CompositeType);
+         if (hasKeyAlias)
 -            cfm.column_metadata.put(cf_def.key_alias, ColumnDefinition.partitionKeyDef(cf_def.key_alias,
cfm.keyValidator, null));
++            cfm.addOrReplaceColumnDefinition(ColumnDefinition.partitionKeyDef(cfm, cf_def.key_alias,
cfm.keyValidator, null));
+ 
+         for (ColumnDefinition def : toUpdate.allColumns())
+         {
+             // isPartOfCellName basically means 'is not just a CQL metadata'
+             if (def.isPartOfCellName())
+                 continue;
+ 
 -            if (def.type == ColumnDefinition.Type.PARTITION_KEY && hasKeyAlias)
++            if (def.kind == ColumnDefinition.Kind.PARTITION_KEY && hasKeyAlias)
+                 continue;
+ 
+             cfm.addOrReplaceColumnDefinition(def);
+         }
+ 
+         return cfm.rebuild();
+     }
+ 
+     // Do most of the work, but don't handle CQL metadata (i.e. skip key_alias and don't
rebuild())
+     private static CFMetaData internalFromThrift(org.apache.cassandra.thrift.CfDef cf_def)
throws InvalidRequestException, ConfigurationException
+     {
          ColumnFamilyType cfType = ColumnFamilyType.create(cf_def.column_type);
          if (cfType == null)
              throw new InvalidRequestException("Invalid column type " + cf_def.column_type);
@@@ -1060,14 -978,12 +1098,11 @@@
              CompressionParameters cp = CompressionParameters.create(cf_def.compression_options);
  
              if (cf_def.isSetKey_validation_class()) { newCFMD.keyValidator(TypeParser.parse(cf_def.key_validation_class));
}
-             if (cf_def.isSetKey_alias() && !(newCFMD.keyValidator instanceof CompositeType))
-                 newCFMD.addOrReplaceColumnDefinition(ColumnDefinition.partitionKeyDef(newCFMD,
cf_def.key_alias, newCFMD.keyValidator, null));
  
 -            return newCFMD.comment(cf_def.comment)
 -                          .replicateOnWrite(cf_def.replicate_on_write)
 +            return newCFMD.addAllColumnDefinitions(ColumnDefinition.fromThrift(newCFMD,
cf_def.column_metadata))
 +                          .comment(cf_def.comment)
                            .defaultValidator(TypeParser.parse(cf_def.default_validation_class))
-                           .compressionParameters(cp)
-                           .rebuild();
 -                          .columnMetadata(ColumnDefinition.fromThrift(cf_def.column_metadata,
newCFMD.isSuper()))
+                           .compressionParameters(cp);
          }
          catch (SyntaxException | MarshalException e)
          {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2269adba/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2269adba/test/unit/org/apache/cassandra/SchemaLoader.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2269adba/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/config/CFMetaDataTest.java
index 47f4f20,b0cafc4..71f21a2
--- a/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
+++ b/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
@@@ -122,11 -121,11 +123,11 @@@ public class CFMetaDataTest extends Sch
  
          // Test thrift conversion
          CFMetaData before = cfm;
-         CFMetaData after = CFMetaData.fromThrift(before.toThrift());
+         CFMetaData after = CFMetaData.fromThriftForUpdate(before.toThrift(), before);
 -        assertThat(after, is(before));
 +        assert before.equals(after) : String.format("%n%s%n!=%n%s", before, after);
  
          // Test schema conversion
 -        RowMutation rm = cfm.toSchema(System.currentTimeMillis());
 +        Mutation rm = cfm.toSchema(System.currentTimeMillis());
          ColumnFamily serializedCf = rm.getColumnFamily(Schema.instance.getId(Keyspace.SYSTEM_KS,
SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF));
          ColumnFamily serializedCD = rm.getColumnFamily(Schema.instance.getId(Keyspace.SYSTEM_KS,
SystemKeyspace.SCHEMA_COLUMNS_CF));
          UntypedResultSet.Row result = QueryProcessor.resultify("SELECT * FROM system.schema_columnfamilies",
new Row(k, serializedCf)).one();


Mime
View raw message