Repository: cassandra Updated Branches: refs/heads/trunk 5cdfa69ca -> 6660970c3
Fix LIMIT with static columns patch by slebresne; reviewed by iamaleksey for CASSANDRA-6956 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/abc6565e Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/abc6565e Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/abc6565e Branch: refs/heads/trunk Commit: abc6565e260d07614a400b0a83a56a20a7a0722f Parents: a90b98e Author: Sylvain Lebresne <sylv...@datastax.com> Authored: Tue Apr 1 11:02:15 2014 +0200 Committer: Sylvain Lebresne <sylv...@datastax.com> Committed: Tue Apr 1 11:02:15 2014 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cassandra/db/filter/ColumnCounter.java | 23 ++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/abc6565e/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 3326c6c..8bfc8b9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -37,6 +37,7 @@ * Add QueryHandler interface (CASSANDRA-6659) * Track liveRatio per-memtable, not per-CF (CASSANDRA-6945) * Make sure upgradesstables keeps sstable level (CASSANDRA-6958) + * Fix LIMT with static columns (CASSANDRA-6956) Merged from 1.2: * Add UNLOGGED, COUNTER options to BATCH documentation (CASSANDRA-6816) * add extra SSL cipher suites (CASSANDRA-6613) http://git-wip-us.apache.org/repos/asf/cassandra/blob/abc6565e/src/java/org/apache/cassandra/db/filter/ColumnCounter.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/filter/ColumnCounter.java b/src/java/org/apache/cassandra/db/filter/ColumnCounter.java index c2c0ade..83b138c 100644 --- a/src/java/org/apache/cassandra/db/filter/ColumnCounter.java +++ b/src/java/org/apache/cassandra/db/filter/ColumnCounter.java @@ -77,7 +77,8 @@ public class ColumnCounter { private final CompositeType type; private final int toGroup; - private ByteBuffer[] last; + private ByteBuffer[] previous; + private boolean previousGroupIsStatic; /** * A column counter that count only 1 for all the columns sharing a @@ -115,12 +116,17 @@ public class ColumnCounter ByteBuffer[] current = type.split(column.name()); assert current.length >= toGroup; - if (last != null) + if (previous == null) + { + // Only the first group can be static + previousGroupIsStatic = type.isStaticName(column.name()); + } + else { boolean isSameGroup = true; for (int i = 0; i < toGroup; i++) { - if (ByteBufferUtil.compareUnsigned(last[i], current[i]) != 0) + if (ByteBufferUtil.compareUnsigned(previous[i], current[i]) != 0) { isSameGroup = false; break; @@ -129,10 +135,19 @@ public class ColumnCounter if (isSameGroup) return; + + // We want to count the static group as 1 (CQL) row only if it's the only + // group in the partition. So, since we have already counted it at this point, + // just don't count the 2nd group if there is one and the first one was static + if (previousGroupIsStatic) + { + previousGroupIsStatic = false; + return; + } } live++; - last = current; + previous = current; } } }