cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [03/19] git commit: Correctly validate sparse composite cells patch by Tyler Hobbs; reviewed by jbellis for CASSANDRA-5855
Date Thu, 08 Aug 2013 22:09:33 GMT
Correctly validate sparse composite cells
patch by Tyler Hobbs; reviewed by jbellis for CASSANDRA-5855


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

Branch: refs/heads/cassandra-2.0
Commit: 9e0efa3dbbeddf382c8e0f45cfdf2ebb91bc9db0
Parents: ccb32a8
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Aug 8 15:33:39 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Aug 8 15:51:34 2013 -0500

----------------------------------------------------------------------
 CHANGES.txt                                  |  2 ++
 src/java/org/apache/cassandra/db/Column.java | 19 ++++++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9e0efa3d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 859e7f9..30ce976 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -13,6 +13,8 @@
  * Future-proof inter-major-version schema migrations (CASSANDRA-5845)
  * (Hadoop) add CqlPagingRecordReader support for ReversedType in Thrift table
    (CASSANDRA-5718)
+Merged from 1.1:
+ * Correctly validate sparse composite cells in scrub (CASSANDRA-5855)
 
 
 1.2.8

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9e0efa3d/src/java/org/apache/cassandra/db/Column.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Column.java b/src/java/org/apache/cassandra/db/Column.java
index 616f3c0..7b614f5 100644
--- a/src/java/org/apache/cassandra/db/Column.java
+++ b/src/java/org/apache/cassandra/db/Column.java
@@ -26,6 +26,7 @@ import java.util.Collection;
 import java.util.List;
 
 import org.apache.cassandra.config.CFMetaData;
+import org.apache.cassandra.cql3.CFDefinition;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.io.util.DataOutputBuffer;
 import org.apache.cassandra.utils.Allocator;
@@ -287,7 +288,23 @@ public class Column implements IColumn
     public void validateFields(CFMetaData metadata) throws MarshalException
     {
         validateName(metadata);
-        AbstractType<?> valueValidator = metadata.getValueValidator(name());
+        CFDefinition cfdef = metadata.getCfDef();
+
+        // If this is a CQL table, we need to pull out the CQL column name to look up the
correct column type.
+        // (Note that COMPACT composites are handled by validateName, above.)
+        ByteBuffer internalName;
+        if (cfdef.isComposite && !cfdef.isCompact)
+        {
+            AbstractCompositeType comparator = (AbstractCompositeType) metadata.comparator;
+            List<AbstractCompositeType.CompositeComponent> components = comparator.deconstruct(name);
+            internalName = components.get(components.size() - 1).value;
+        }
+        else
+        {
+            internalName = name;
+        }
+
+        AbstractType<?> valueValidator = metadata.getValueValidator(internalName);
         if (valueValidator != null)
             valueValidator.validate(value());
     }


Mime
View raw message