Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 3e37b4a90 -> 22d6f649f


Fix paging on DISTINCT queries repeats result when first row in partition 
changes

patch by Benjamin Lerer; reviewed by Sylvain Lebresne for CASSANDRA-10010


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

Branch: refs/heads/cassandra-3.0
Commit: fa2fa602d989ed911b60247e3dd8f2d580188782
Parents: dd76858
Author: Benjamin Lerer <b.le...@gmail.com>
Authored: Wed Jan 27 17:21:22 2016 +0100
Committer: Benjamin Lerer <b.le...@gmail.com>
Committed: Wed Jan 27 17:21:22 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                               |  2 ++
 .../cassandra/service/pager/RangeSliceQueryPager.java     | 10 ++++++++++
 2 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/fa2fa602/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index cdc3b34..9847371 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,5 @@
+2.2.6
+ * Fix paging on DISTINCT queries repeats result when first row in partition 
changes (CASSANDRA-10010)
 2.2.5
  * maxPurgeableTimestamp needs to check memtables too (CASSANDRA-9949)
  * Apply change to compaction throughput in real time (CASSANDRA-10025)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/fa2fa602/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java
----------------------------------------------------------------------
diff --git 
a/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java 
b/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java
index 10e470b..8ec9f4c 100644
--- a/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java
+++ b/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java
@@ -97,6 +97,10 @@ public class RangeSliceQueryPager extends AbstractQueryPager
         if (lastReturnedKey == null || !lastReturnedKey.equals(first.key))
             return false;
 
+        // If the query is a DISTINCT one we can stop there
+        if (isDistinct())
+            return true;
+
         // Same as SliceQueryPager, we ignore a deleted column
         Cell firstCell = isReversed() ? lastCell(first.cf) : 
firstNonStaticCell(first.cf);
         // If the row was containing only static columns it has already been 
returned and we can skip it.
@@ -109,6 +113,12 @@ public class RangeSliceQueryPager extends 
AbstractQueryPager
                 && firstCell.name().isSameCQL3RowAs(metadata.comparator, 
lastReturnedName);
     }
 
+    private boolean isDistinct()
+    {
+        // As this pager is never used for Thrift queries, checking the 
countCQL3Rows is enough.
+        return !command.countCQL3Rows;
+    }
+
     protected boolean recordLast(Row last)
     {
         lastReturnedKey = last.key;

Reply via email to