Repository: cassandra Updated Branches: refs/heads/cassandra-2.2 280da1843 -> bf40aa443
Fix paging on DISTINCT queries repeats result when first row in partition changes patch by Benjamin Lerer; reviewed by Tyler Hobbs for CASSANDRA-11679 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f5baa9c7 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f5baa9c7 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f5baa9c7 Branch: refs/heads/cassandra-2.2 Commit: f5baa9c712c283d7f9897dfbb9ca269b2f5a3de3 Parents: fccded5 Author: Benjamin Lerer <b.le...@gmail.com> Authored: Fri May 13 21:07:27 2016 +0200 Committer: Benjamin Lerer <b.le...@gmail.com> Committed: Fri May 13 21:07:27 2016 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cassandra/service/pager/RangeSliceQueryPager.java | 11 +++++++++++ 2 files changed, 12 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/f5baa9c7/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index edf5aa3..e407140 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.1.15 + * Fix paging on DISTINCT queries repeats result when first row in partition changes (CASSANDRA-11679) * Add option to disable use of severity in DynamicEndpointSnitch (CASSANDRA-11737) * cqlsh COPY FROM fails for null values with non-prepared statements (CASSANDRA-11631) * Make cython optional in pylib/setup.py (CASSANDRA-11630) http://git-wip-us.apache.org/repos/asf/cassandra/blob/f5baa9c7/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 fd14c82..caa146a 100644 --- a/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java +++ b/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java @@ -96,8 +96,13 @@ 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. if (firstCell == null) return true; @@ -108,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;