cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [2/3] git commit: Fix scrubbing of CQL3 create tables
Date Wed, 26 Sep 2012 12:10:25 GMT
Fix scrubbing of CQL3 create tables

patch by slebresne; reviewed by jbellis for CASSANDRA-4685


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

Branch: refs/heads/trunk
Commit: 2d76556742998ca332e562aba3398ab49c803d67
Parents: ccca5f1
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Sep 26 14:06:37 2012 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Sep 26 14:06:37 2012 +0200

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../org/apache/cassandra/config/CFMetaData.java    |   21 ++++++++++++--
 .../apache/cassandra/thrift/ThriftValidation.java  |   22 +--------------
 3 files changed, 20 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d765567/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b70c412..9972c7c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,7 @@
    movement (CASSANDRA-833)
  * Change CQL version to 3.0.0 and stop accepting 3.0.0-beta1 (CASSANDRA-4649)
  * Make prepared statement global instead of per connection (CASSANDRA-4449)
+ * Fix scrubbing of CQL3 created tables (CASSANDRA-4685)
 
 1.2-beta1
  * add atomic_batch_mutate (CASSANDRA-4542, -4635)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d765567/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 f5c2293..f15ca00 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -646,7 +646,7 @@ public final class CFMetaData
 
     public AbstractType<?> getValueValidator(ByteBuffer column)
     {
-        return getValueValidator(column_metadata.get(column));
+        return getValueValidator(getColumnDefinition(column));
     }
 
     public AbstractType<?> getValueValidator(ColumnDefinition columnDefinition)
@@ -932,9 +932,24 @@ public final class CFMetaData
         return def;
     }
 
-    public ColumnDefinition getColumnDefinition(ByteBuffer name)
+    public ColumnDefinition getColumnDefinition(ByteBuffer columnName)
     {
-        return column_metadata.get(name);
+        if (comparator instanceof CompositeType)
+        {
+            CompositeType composite = (CompositeType)comparator;
+            ByteBuffer[] components = composite.split(columnName);
+            for (ColumnDefinition def : column_metadata.values())
+            {
+                ByteBuffer toCompare = def.componentIndex == null ? columnName : components[def.componentIndex];
+                if (def.name.equals(toCompare))
+                    return def;
+            }
+            return null;
+        }
+        else
+        {
+            return column_metadata.get(columnName);
+        }
     }
 
     public ColumnDefinition getColumnDefinitionForIndex(String indexName)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d765567/src/java/org/apache/cassandra/thrift/ThriftValidation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftValidation.java b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
index 93b972d..b1b6c24 100644
--- a/src/java/org/apache/cassandra/thrift/ThriftValidation.java
+++ b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
@@ -396,7 +396,7 @@ public class ThriftValidation
         if (!column.isSetTimestamp())
             throw new org.apache.cassandra.exceptions.InvalidRequestException("Column timestamp
is required");
 
-        ColumnDefinition columnDef = getColumnDefinition(metadata, column.name);
+        ColumnDefinition columnDef = metadata.getColumnDefinition(column.name);
         try
         {
             AbstractType<?> validator = metadata.getValueValidator(columnDef);
@@ -423,26 +423,6 @@ public class ThriftValidation
                                                                               metadata.ksName));
     }
 
-    private static ColumnDefinition getColumnDefinition(CFMetaData metadata, ByteBuffer columnName)
-    {
-        if (metadata.comparator instanceof CompositeType)
-        {
-            CompositeType composite = (CompositeType)metadata.comparator;
-            ByteBuffer[] components = composite.split(columnName);
-            for (ColumnDefinition def : metadata.getColumn_metadata().values())
-            {
-                ByteBuffer toCompare = def.componentIndex == null ? columnName : components[def.componentIndex];
-                if (columnName.equals(toCompare))
-                    return def;
-            }
-            return null;
-        }
-        else
-        {
-            return metadata.getColumnDefinition(columnName);
-        }
-    }
-
     /**
      * Return, at most, the first 64K of the buffer. This avoids very large column values
being
      * logged in their entirety.


Mime
View raw message