Use correct bounds for all-data range when filtering Patch by Alex Petrov; reviewed by Branimir Lambov for CASSANDRA-12666.
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f00e4316 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f00e4316 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f00e4316 Branch: refs/heads/trunk Commit: f00e43167ab11f58af20439a300bdf82664abdb0 Parents: 8de24ca Author: Alex Petrov <oleksandr.pet...@gmail.com> Authored: Sun Sep 18 11:09:47 2016 +0200 Committer: Branimir Lambov <branimir.lam...@datastax.com> Committed: Wed Nov 30 14:39:33 2016 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cql3/restrictions/StatementRestrictions.java | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/f00e4316/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 72d6a1f..b238018 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.10 + * Use correct bounds for all-data range when filtering (CASSANDRA-12666) * Remove timing window in test case (CASSANDRA-12875) * Resolve unit testing without JCE security libraries installed (CASSANDRA-12945) * Fix inconsistencies in cassandra-stress load balancing policy (CASSANDRA-12919) http://git-wip-us.apache.org/repos/asf/cassandra/blob/f00e4316/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java b/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java index 53ac68c..2d04633 100644 --- a/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java +++ b/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java @@ -624,11 +624,6 @@ public final class StatementRestrictions */ private ByteBuffer getPartitionKeyBound(Bound b, QueryOptions options) { - // Deal with unrestricted partition key components (special-casing is required to deal with 2i queries on the - // first component of a composite partition key) queries that filter on the partition key. - if (partitionKeyRestrictions.needFiltering(cfm)) - return ByteBufferUtil.EMPTY_BYTE_BUFFER; - // We deal with IN queries for keys in other places, so we know buildBound will return only one result return partitionKeyRestrictions.bounds(b, options).get(0); } @@ -654,6 +649,11 @@ public final class StatementRestrictions private AbstractBounds<PartitionPosition> getPartitionKeyBounds(IPartitioner p, QueryOptions options) { + // Deal with unrestricted partition key components (special-casing is required to deal with 2i queries on the + // first component of a composite partition key) queries that filter on the partition key. + if (partitionKeyRestrictions.needFiltering(cfm)) + return new Range<>(p.getMinimumToken().minKeyBound(), p.getMinimumToken().maxKeyBound()); + ByteBuffer startKeyBytes = getPartitionKeyBound(Bound.START, options); ByteBuffer finishKeyBytes = getPartitionKeyBound(Bound.END, options);