Repository: cassandra Updated Branches: refs/heads/cassandra-3.0 a88073918 -> 1b5e3a9b1
Fix paging issues with partitions containing only static columns data patch by Benjamin Lerer; reviewed by Sylvain Lebresne for CASSANDRA-10381 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/328916d1 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/328916d1 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/328916d1 Branch: refs/heads/cassandra-3.0 Commit: 328916d1591be69f217f6519304651d3757d9e1d Parents: 9b3b1cb Author: blerer <benjamin.le...@datastax.com> Authored: Tue Oct 20 14:33:50 2015 +0200 Committer: blerer <benjamin.le...@datastax.com> Committed: Tue Oct 20 14:33:50 2015 +0200 ---------------------------------------------------------------------- CHANGES.txt | 2 ++ .../apache/cassandra/service/pager/AbstractQueryPager.java | 6 +++++- .../cassandra/service/pager/RangeSliceQueryPager.java | 8 ++++++-- .../org/apache/cassandra/service/pager/SliceQueryPager.java | 9 +++++++-- 4 files changed, 20 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/328916d1/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index b17929c..dbb3480 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,6 @@ 2.1.12 + * Fix paging issues with partitions containing only static columns data + (CASSANDRA-10381) * Fix conditions on static columns (CASSANDRA-10264) * AssertionError: attempted to delete non-existing file CommitLog (CASSANDRA-10377) * Merge range tombstones during compaction (CASSANDRA-7953) http://git-wip-us.apache.org/repos/asf/cassandra/blob/328916d1/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java b/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java index a3991ed..6056b9a 100644 --- a/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java +++ b/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java @@ -345,7 +345,11 @@ abstract class AbstractQueryPager implements QueryPager copy.addColumn(iter.next()); } } - return Math.min(counter.live(), toDiscard); + int live = counter.live(); + // We want to take into account the row even if it was containing only static columns + if (live == 0 && !staticCells.isEmpty()) + live = 1; + return Math.min(live, toDiscard); } private int discardTail(ColumnFamily cf, int toDiscard, ColumnFamily copy, Iterator<Cell> iter, DeletionInfo.InOrderTester tester) http://git-wip-us.apache.org/repos/asf/cassandra/blob/328916d1/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 e02bb46..fd14c82 100644 --- a/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java +++ b/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java @@ -98,10 +98,14 @@ public class RangeSliceQueryPager extends AbstractQueryPager // 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; + CFMetaData metadata = Schema.instance.getCFMetaData(command.keyspace, command.columnFamily); return !first.cf.deletionInfo().isDeleted(firstCell) - && firstCell.isLive(timestamp()) - && firstCell.name().isSameCQL3RowAs(metadata.comparator, lastReturnedName); + && firstCell.isLive(timestamp()) + && firstCell.name().isSameCQL3RowAs(metadata.comparator, lastReturnedName); } protected boolean recordLast(Row last) http://git-wip-us.apache.org/repos/asf/cassandra/blob/328916d1/src/java/org/apache/cassandra/service/pager/SliceQueryPager.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/pager/SliceQueryPager.java b/src/java/org/apache/cassandra/service/pager/SliceQueryPager.java index c8572d4..1a2fc6c 100644 --- a/src/java/org/apache/cassandra/service/pager/SliceQueryPager.java +++ b/src/java/org/apache/cassandra/service/pager/SliceQueryPager.java @@ -102,12 +102,17 @@ public class SliceQueryPager extends AbstractQueryPager implements SinglePartiti return false; 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; + CFMetaData metadata = Schema.instance.getCFMetaData(command.getKeyspace(), command.getColumnFamilyName()); // Note: we only return true if the column is the lastReturned *and* it is live. If it is deleted, it is ignored by the // rest of the paging code (it hasn't been counted as live in particular) and we want to act as if it wasn't there. + return !first.cf.deletionInfo().isDeleted(firstCell) - && firstCell.isLive(timestamp()) - && firstCell.name().isSameCQL3RowAs(metadata.comparator, lastReturned); + && firstCell.isLive(timestamp()) + && firstCell.name().isSameCQL3RowAs(metadata.comparator, lastReturned); } protected boolean recordLast(Row last)