cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [11/19] git commit: make scrubbing collection-aware
Date Thu, 08 Aug 2013 22:09:41 GMT
make scrubbing collection-aware


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

Branch: refs/heads/cassandra-1.2
Commit: 73b0ffba82f431d6fca2a876504fe9f0631ef0a6
Parents: 9e0efa3
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Aug 8 17:06:56 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Aug 8 17:06:56 2013 -0500

----------------------------------------------------------------------
 src/java/org/apache/cassandra/db/Column.java    | 13 +++--------
 .../cassandra/db/marshal/CompositeType.java     | 24 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/73b0ffba/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 7b614f5..632392f 100644
--- a/src/java/org/apache/cassandra/db/Column.java
+++ b/src/java/org/apache/cassandra/db/Column.java
@@ -293,16 +293,9 @@ public class Column implements IColumn
         // 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;
-        }
+        internalName = (cfdef.isComposite && !cfdef.isCompact)
+                     ? ((CompositeType) metadata.comparator).extractLastComponent(name)
+                     : name;
 
         AbstractType<?> valueValidator = metadata.getValueValidator(internalName);
         if (valueValidator != null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/73b0ffba/src/java/org/apache/cassandra/db/marshal/CompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/CompositeType.java b/src/java/org/apache/cassandra/db/marshal/CompositeType.java
index 522be13..2a27617 100644
--- a/src/java/org/apache/cassandra/db/marshal/CompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/CompositeType.java
@@ -124,6 +124,30 @@ public class CompositeType extends AbstractCompositeType
         return build(serialized);
     }
 
+    // Extract component idx from bb. Return null if there is not enough component.
+    public static ByteBuffer extractComponent(ByteBuffer bb, int idx)
+    {
+        bb = bb.duplicate();
+        int i = 0;
+        while (bb.remaining() > 0)
+        {
+            ByteBuffer c = getWithShortLength(bb);
+            if (i == idx)
+                return c;
+
+            bb.get(); // skip end-of-component
+            ++i;
+        }
+        return null;
+    }
+
+    // Extract CQL3 column name from the full column name.
+    public ByteBuffer extractLastComponent(ByteBuffer bb)
+    {
+        int idx = types.get(types.size() - 1) instanceof ColumnToCollectionType ? types.size()
- 2 : types.size() - 1;
+        return extractComponent(bb, idx);
+    }
+
     @Override
     public boolean isCompatibleWith(AbstractType<?> previous)
     {


Mime
View raw message