cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [1/2] git commit: Don't return range ghosts in CQL3
Date Tue, 15 May 2012 07:08:56 GMT
Updated Branches:
  refs/heads/cassandra-1.1 68bae3131 -> 0cee56b17


Don't return range ghosts in CQL3

patch by slebresne; reviewed by jbellis for CASSANDRA-3982


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

Branch: refs/heads/cassandra-1.1
Commit: 0cee56b1720e1e1ee8e81a813d026c8b0e180070
Parents: 983ee11
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Tue May 15 09:07:56 2012 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Tue May 15 09:07:56 2012 +0200

----------------------------------------------------------------------
 CHANGES.txt                                        |    3 +-
 .../cassandra/cql3/statements/SelectStatement.java |   46 +++++++-------
 2 files changed, 25 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/0cee56b1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b37bd83..1a5a7b7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -40,7 +40,8 @@
    (CASSANDRA-4187)
  * Fix exception during move when localhost is the only source (CASSANDRA-4200)
  * (cql3) Allow paging through non-ordered partitioner results (CASSANDRA-3771)
- * (cql3) Fix drop index
+ * (cql3) Fix drop index (CASSANDRA-4192)
+ * (cql3) Don't return range ghosts anymore (CASSANDRA-3982)
 Merged from 1.0:
  * Fix super columns bug where cache is not updated (CASSANDRA-4190)
  * fix maxTimestamp to include row tombstones (CASSANDRA-4116)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0cee56b1/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index 1878949..425cf17 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -467,18 +467,18 @@ public class SelectStatement implements CQLStatement
         }
         else
         {
-            // Adds all (requested) columns
-            List<Pair<CFDefinition.Name, ColumnIdentifier>> selection = getExpandedSelection();
-            List<ByteBuffer> columns = new ArrayList<ByteBuffer>(selection.size());
-            Iterator<Pair<CFDefinition.Name, ColumnIdentifier>> iter = selection.iterator();
+            // Adds all columns (even if the user selected a few columns, we
+            // need to query all columns to know if the row exists or not).
+            // Note that when we allow IS NOT NULL in queries and if all
+            // selected name are request 'not null', we will allow to only
+            // query those.
+            List<ByteBuffer> columns = new ArrayList<ByteBuffer>(cfDef.columns.size());
+            Iterator<ColumnIdentifier> iter = cfDef.metadata.keySet().iterator();
             while (iter.hasNext())
             {
-                CFDefinition.Name name = iter.next().left;
-                // Skip everything that is not a 'metadata' column
-                if (name.kind != CFDefinition.Name.Kind.COLUMN_METADATA)
-                    continue;
+                ColumnIdentifier name = iter.next();
                 ColumnNameBuilder b = iter.hasNext() ? builder.copy() : builder;
-                ByteBuffer cname = b.add(name.name.key).build();
+                ByteBuffer cname = b.add(name.key).build();
                 columns.add(cname);
             }
             return columns;
@@ -626,14 +626,19 @@ public class SelectStatement implements CQLStatement
         List<Pair<CFDefinition.Name, ColumnIdentifier>> selection = getExpandedSelection();
         List<Column> thriftColumns = null;
 
+        // Add schema only once
+        for (Pair<CFDefinition.Name, ColumnIdentifier> p : selection)
+            addToSchema(schema, p);
+
         for (org.apache.cassandra.db.Row row : rows)
         {
+            // Not columns match the query, skip
+            if (row.cf == null)
+                continue;
+
             if (cfDef.isCompact)
             {
                 // One cqlRow per column
-                if (row.cf == null)
-                    continue;
-
                 for (IColumn c : columnsInOrder(row.cf, variables))
                 {
                     if (c.isMarkedForDelete())
@@ -662,7 +667,6 @@ public class SelectStatement implements CQLStatement
                         CFDefinition.Name name = p.left;
                         ByteBuffer nameAsRequested = p.right.key;
 
-                        addToSchema(schema, p);
                         Column col = new Column(nameAsRequested);
                         switch (name.kind)
                         {
@@ -698,9 +702,6 @@ public class SelectStatement implements CQLStatement
             else if (cfDef.isComposite)
             {
                 // Sparse case: group column in cqlRow when composite prefix is equal
-                if (row.cf == null)
-                    continue;
-
                 CompositeType composite = (CompositeType)cfDef.cfm.comparator;
                 int last = composite.types.size() - 1;
 
@@ -729,8 +730,12 @@ public class SelectStatement implements CQLStatement
             }
             else
             {
+                if (row.cf.getLiveColumnCount() == 0)
+                    continue;
+
                 // Static case: One cqlRow for all columns
                 thriftColumns = new ArrayList<Column>(selection.size());
+
                 // Respect selection order
                 for (Pair<CFDefinition.Name, ColumnIdentifier> p : selection)
                 {
@@ -739,15 +744,10 @@ public class SelectStatement implements CQLStatement
 
                     if (name.kind == CFDefinition.Name.Kind.KEY_ALIAS)
                     {
-                        addToSchema(schema, p);
                         thriftColumns.add(new Column(nameAsRequested).setValue(row.key.key).setTimestamp(-1L));
                         continue;
                     }
 
-                    if (row.cf == null)
-                        continue;
-
-                    addToSchema(schema, p);
                     IColumn c = row.cf.getColumn(name.name.key);
                     Column col = new Column(name.name.key);
                     if (c != null && !c.isMarkedForDelete())
@@ -799,7 +799,6 @@ public class SelectStatement implements CQLStatement
             CFDefinition.Name name = p.left;
             ByteBuffer nameAsRequested = p.right.key;
 
-            addToSchema(schema, p);
             Column col = new Column(nameAsRequested);
             switch (name.kind)
             {
@@ -815,7 +814,8 @@ public class SelectStatement implements CQLStatement
                     throw new AssertionError();
                 case COLUMN_METADATA:
                     IColumn c = columns.get(name.name.key);
-                    if (c != null && !c.isMarkedForDelete())
+                    // We already have excluded deleted columns
+                    if (c != null)
                         col.setValue(value(c)).setTimestamp(c.timestamp());
                     break;
             }


Mime
View raw message