You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2012/09/18 08:35:29 UTC
git commit: (cql3) Fix queries using LIMIT missing results
Updated Branches:
refs/heads/trunk 12691ae3a -> 6fc30803e
(cql3) Fix queries using LIMIT missing results
patch by slebresne; reviewed by xedin for CASSANDRA-4579
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/6fc30803
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/6fc30803
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/6fc30803
Branch: refs/heads/trunk
Commit: 6fc30803e13e9d73f3d1a8141bc306f251e734d4
Parents: 12691ae
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Tue Sep 18 08:34:23 2012 +0200
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Tue Sep 18 08:34:23 2012 +0200
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../cassandra/cql3/statements/SelectStatement.java | 7 ++++++-
.../cassandra/db/filter/SliceQueryFilter.java | 13 ++++++-------
3 files changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/6fc30803/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3235855..1dd875e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -63,6 +63,7 @@
* Add sstable count per level to cfstats (CASSANDRA-4537)
* (cql3) Add ALTER KEYSPACE statement (CASSANDRA-4611)
* (cql3) Allow defining default consistency levels (CASSANDRA-4448)
+ * (cql3) Fix queries using LIMIT missing results (CASSANDRA-4579)
1.1.6
http://git-wip-us.apache.org/repos/asf/cassandra/blob/6fc30803/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 1c2b631..26086ad 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -196,6 +196,11 @@ public class SelectStatement implements CQLStatement
try
{
+ // The LIMIT provided by the user is the number of CQL row he wants returned.
+ // For NamesQueryFilter, this is the number of internal rows returned, since a NamesQueryFilter can only select one CQL row in a given internal row.
+ // For SliceQueryFilter however, we want to have getRangeSlice to count the number of columns, not the number of keys. Then
+ // SliceQueryFilter.collectReducedColumns will correctly columns having the same composite prefix using ColumnCounter.
+ boolean maxIsColumns = filter instanceof SliceQueryFilter;
rows = StorageProxy.getRangeSlice(new RangeSliceCommand(keyspace(),
columnFamily(),
null,
@@ -203,7 +208,7 @@ public class SelectStatement implements CQLStatement
getKeyBounds(variables),
expressions,
getLimit(),
- true, // limit by columns, not keys
+ maxIsColumns,
false),
getConsistencyLevel());
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/6fc30803/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java b/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
index 6b36f4e..2de284a 100644
--- a/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
+++ b/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
@@ -149,13 +149,6 @@ public class SliceQueryFilter implements IFilter
while (reducedColumns.hasNext())
{
- if (columnCounter.live() >= count)
- {
- logger.debug("Read %s live columns and %s tombstoned",
- columnCounter.live(), columnCounter.ignored());
- break;
- }
-
IColumn column = reducedColumns.next();
if (logger.isTraceEnabled())
logger.trace(String.format("collecting %s of %s: %s",
@@ -163,6 +156,12 @@ public class SliceQueryFilter implements IFilter
columnCounter.count(column, container);
+ if (columnCounter.live() > count)
+ {
+ logger.debug("Read %s live columns and %s tombstoned", columnCounter.live(), columnCounter.ignored());
+ break;
+ }
+
// but we need to add all non-gc-able columns to the result for read repair:
if (QueryFilter.isRelevant(column, container, gcBefore))
container.addColumn(column);