cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [01/16] git commit: Correctly validate sparse composite cells patch by Tyler Hobbs; reviewed by jbellis for CASSANDRA-5855
Date Thu, 08 Aug 2013 20:52:23 GMT
Updated Branches:
  refs/heads/cassandra-1.2 ccb32a8c8 -> 9e0efa3db
  refs/heads/cassandra-2.0 5d9a33a46 -> e911b767e
  refs/heads/cassandra-2.0.0 7a8cbb3ea -> 5411e5ff8
  refs/heads/trunk 28b827a85 -> a1212c597


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/eb884a58
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/eb884a58
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/eb884a58

Branch: refs/heads/cassandra-2.0
Commit: eb884a582b709d67fdd075aedf19facf6803bf93
Parents: 238139c
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:43:43 2013 -0500

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


http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb884a58/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 75b349f..8790518 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,6 @@
 1.1.next
  * Backport compaction exception handling from 1.2
+ * Correctly validate sparse composite cells in scrub (CASSANDRA-5855)
 
 
 1.1.12

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eb884a58/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 97aece0..ea83146 100644
--- a/src/java/org/apache/cassandra/db/Column.java
+++ b/src/java/org/apache/cassandra/db/Column.java
@@ -29,6 +29,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 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;
@@ -277,7 +278,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