cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject cassandra git commit: Fix column dropping
Date Tue, 14 Jul 2015 09:01:54 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk fbf52e65f -> 4c12f1961


Fix column dropping

patch by slebresne; reviewed by iamaleksey for CASSANDRA-9781


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

Branch: refs/heads/trunk
Commit: 4c12f1961b1a84f37c3eab8fc83a8640693d5665
Parents: fbf52e6
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Tue Jul 14 11:00:57 2015 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Tue Jul 14 11:01:46 2015 +0200

----------------------------------------------------------------------
 CHANGES.txt                                                  | 2 +-
 src/java/org/apache/cassandra/config/CFMetaData.java         | 8 ++++----
 .../cassandra/cql3/statements/AlterTableStatement.java       | 4 ++--
 .../db/partitions/UnfilteredPartitionIterators.java          | 7 ++++---
 .../org/apache/cassandra/schema/LegacySchemaMigrator.java    | 2 +-
 src/java/org/apache/cassandra/schema/SchemaKeyspace.java     | 6 +++---
 .../apache/cassandra/schema/LegacySchemaMigratorTest.java    | 4 ++--
 7 files changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c12f196/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index bdc30d7..f484748 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,7 +1,7 @@
 3.0
  * Change CREATE/ALTER TABLE syntax for compression (CASSANDRA-8384)
  * Cleanup crc and adler code for java 8 (CASSANDRA-9650)
- * Storage engine refactor (CASSANDRA-8099, 9743, 9746, 9759)
+ * Storage engine refactor (CASSANDRA-8099, 9743, 9746, 9759, 9781)
  * Update Guava to 18.0 (CASSANDRA-9653)
  * Bloom filter false positive ratio is not honoured (CASSANDRA-8413)
  * New option for cassandra-stress to leave a ratio of columns null (CASSANDRA-9522)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c12f196/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java
index 8ae5e93..1219952 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -191,7 +191,7 @@ public final class CFMetaData
     private volatile int memtableFlushPeriod = 0;
     private volatile int defaultTimeToLive = DEFAULT_DEFAULT_TIME_TO_LIVE;
     private volatile SpeculativeRetry speculativeRetry = DEFAULT_SPECULATIVE_RETRY;
-    private volatile Map<ColumnIdentifier, DroppedColumn> droppedColumns = new HashMap<>();
+    private volatile Map<ByteBuffer, DroppedColumn> droppedColumns = new HashMap<>();
     private volatile Triggers triggers = Triggers.none();
 
     /*
@@ -236,7 +236,7 @@ public final class CFMetaData
     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 droppedColumns(Map<ColumnIdentifier, DroppedColumn> cols) {droppedColumns
= cols; return this;}
+    public CFMetaData droppedColumns(Map<ByteBuffer, DroppedColumn> cols) {droppedColumns
= cols; return this;}
     public CFMetaData triggers(Triggers prop) {triggers = prop; return this;}
 
     private CFMetaData(String keyspace,
@@ -687,7 +687,7 @@ public final class CFMetaData
         return defaultTimeToLive;
     }
 
-    public Map<ColumnIdentifier, DroppedColumn> getDroppedColumns()
+    public Map<ByteBuffer, DroppedColumn> getDroppedColumns()
     {
         return droppedColumns;
     }
@@ -1190,7 +1190,7 @@ public final class CFMetaData
 
     public void recordColumnDrop(ColumnDefinition def)
     {
-        droppedColumns.put(def.name, new DroppedColumn(def.type, FBUtilities.timestampMicros()));
+        droppedColumns.put(def.name.bytes, new DroppedColumn(def.type, FBUtilities.timestampMicros()));
     }
 
     public void renameColumn(ColumnIdentifier from, ColumnIdentifier to) throws InvalidRequestException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c12f196/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
index b6937af..2cd3f68 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
@@ -116,7 +116,7 @@ public class AlterTableStatement extends SchemaAlteringStatement
                 }
 
                 // Cannot re-add a dropped counter column. See #7831.
-                if (meta.isCounter() && meta.getDroppedColumns().containsKey(columnName))
+                if (meta.isCounter() && meta.getDroppedColumns().containsKey(columnName.bytes))
                     throw new InvalidRequestException(String.format("Cannot re-add previously
dropped counter column %s", columnName));
 
                 AbstractType<?> type = validator.getType();
@@ -130,7 +130,7 @@ public class AlterTableStatement extends SchemaAlteringStatement
                     // If there used to be a collection column with the same name (that has
been dropped), we could still have
                     // some data using the old type, and so we can't allow adding a collection
with the same name unless
                     // the types are compatible (see #6276).
-                    CFMetaData.DroppedColumn dropped = cfm.getDroppedColumns().get(columnName);
+                    CFMetaData.DroppedColumn dropped = cfm.getDroppedColumns().get(columnName.bytes);
                     // We could have type == null for old dropped columns, in which case
we play it safe and refuse
                     if (dropped != null && (dropped.type == null || (dropped.type
instanceof CollectionType && !type.isCompatibleWith(dropped.type))))
                         throw new InvalidRequestException(String.format("Cannot add a collection
with the name %s " +

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c12f196/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java
b/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java
index f66ec11..8b2ef03 100644
--- a/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java
+++ b/src/java/org/apache/cassandra/db/partitions/UnfilteredPartitionIterators.java
@@ -20,6 +20,7 @@ package org.apache.cassandra.db.partitions;
 import java.io.DataInput;
 import java.io.IOError;
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.security.MessageDigest;
 import java.util.*;
 
@@ -329,7 +330,7 @@ public abstract class UnfilteredPartitionIterators
         };
     }
 
-    public static UnfilteredPartitionIterator removeDroppedColumns(UnfilteredPartitionIterator
iterator, final Map<ColumnIdentifier, CFMetaData.DroppedColumn> droppedColumns)
+    public static UnfilteredPartitionIterator removeDroppedColumns(UnfilteredPartitionIterator
iterator, final Map<ByteBuffer, CFMetaData.DroppedColumn> droppedColumns)
     {
         return new FilteringPartitionIterator(iterator)
         {
@@ -352,7 +353,7 @@ public abstract class UnfilteredPartitionIterators
 
                     private boolean include(ColumnDefinition column, long timestamp)
                     {
-                        CFMetaData.DroppedColumn dropped = droppedColumns.get(column.name);
+                        CFMetaData.DroppedColumn dropped = droppedColumns.get(column.name.bytes);
                         return dropped == null || timestamp > dropped.droppedTime;
                     }
                 };
@@ -367,7 +368,7 @@ public abstract class UnfilteredPartitionIterators
 
                 // If none of the dropped columns is part of the columns that the iterator
actually returns, there is nothing to do;
                 for (ColumnDefinition c : iterator.columns())
-                    if (droppedColumns.containsKey(c.name))
+                    if (droppedColumns.containsKey(c.name.bytes))
                         return true;
 
                 return false;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c12f196/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java b/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
index 79243f4..8e374d6 100644
--- a/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
+++ b/src/java/org/apache/cassandra/schema/LegacySchemaMigrator.java
@@ -403,7 +403,7 @@ public final class LegacySchemaMigrator
             String name = entry.getKey();
             long time = entry.getValue();
             AbstractType<?> type = types.containsKey(name) ? TypeParser.parse(types.get(name))
: null;
-            cfm.getDroppedColumns().put(ColumnIdentifier.getInterned(name, true), new CFMetaData.DroppedColumn(type,
time));
+            cfm.getDroppedColumns().put(UTF8Type.instance.decompose(name), new CFMetaData.DroppedColumn(type,
time));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c12f196/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/schema/SchemaKeyspace.java b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
index 979f973..d17b794 100644
--- a/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
+++ b/src/java/org/apache/cassandra/schema/SchemaKeyspace.java
@@ -841,9 +841,9 @@ public final class SchemaKeyspace
              .add("read_repair_chance", table.getReadRepairChance())
              .add("speculative_retry", table.getSpeculativeRetry().toString());
 
-        for (Map.Entry<ColumnIdentifier, CFMetaData.DroppedColumn> entry : table.getDroppedColumns().entrySet())
+        for (Map.Entry<ByteBuffer, CFMetaData.DroppedColumn> entry : table.getDroppedColumns().entrySet())
         {
-            String name = entry.getKey().toString();
+            String name = UTF8Type.instance.getString(entry.getKey());
             CFMetaData.DroppedColumn column = entry.getValue();
             adder.addMapEntry("dropped_columns", name, column.droppedTime);
             if (column.type != null)
@@ -1073,7 +1073,7 @@ public final class SchemaKeyspace
             String name = entry.getKey();
             long time = entry.getValue();
             AbstractType<?> type = types.containsKey(name) ? TypeParser.parse(types.get(name))
: null;
-            cfm.getDroppedColumns().put(ColumnIdentifier.getInterned(name, true), new CFMetaData.DroppedColumn(type,
time));
+            cfm.getDroppedColumns().put(UTF8Type.instance.decompose(name), new CFMetaData.DroppedColumn(type,
time));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4c12f196/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java b/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
index 4a6bb01..c94681e 100644
--- a/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
+++ b/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
@@ -403,9 +403,9 @@ public class LegacySchemaMigratorTest
              .add("read_repair_chance", table.getReadRepairChance())
              .add("speculative_retry", table.getSpeculativeRetry().toString());
 
-        for (Map.Entry<ColumnIdentifier, CFMetaData.DroppedColumn> entry : table.getDroppedColumns().entrySet())
+        for (Map.Entry<ByteBuffer, CFMetaData.DroppedColumn> entry : table.getDroppedColumns().entrySet())
         {
-            String name = entry.getKey().toString();
+            String name = UTF8Type.instance.getString(entry.getKey());
             CFMetaData.DroppedColumn column = entry.getValue();
             adder.addMapEntry("dropped_columns", name, column.droppedTime);
         }


Mime
View raw message