Repository: cassandra Updated Branches: refs/heads/cassandra-3.0 a8b8515c8 -> e5e291044
Fix repeated slices on AbstractThreadUnsafePartition.SliceableIterator Patch by Tyler Hobbs; reviewed by Stefania Alborghetti for CASSANDRA-10002 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e5e29104 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e5e29104 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e5e29104 Branch: refs/heads/cassandra-3.0 Commit: e5e29104436fbccb9fb202c3305765ffde6f16b8 Parents: a8b8515 Author: Tyler Hobbs <[email protected]> Authored: Fri Aug 7 14:19:00 2015 -0500 Committer: Tyler Hobbs <[email protected]> Committed: Fri Aug 7 14:19:00 2015 -0500 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../db/partitions/AbstractThreadUnsafePartition.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/e5e29104/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 13614cc..7549e70 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.0.0-beta1 + * Fix multiple slices on RowSearchers (CASSANDRA-10002) * Fix bug in merging of collections (CASSANDRA-10001) * Optimize batchlog replay to avoid full scans (CASSANDRA-7237) * Repair improvements when using vnodes (CASSANDRA-5220) http://git-wip-us.apache.org/repos/asf/cassandra/blob/e5e29104/src/java/org/apache/cassandra/db/partitions/AbstractThreadUnsafePartition.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/partitions/AbstractThreadUnsafePartition.java b/src/java/org/apache/cassandra/db/partitions/AbstractThreadUnsafePartition.java index a716768..acdd0e2 100644 --- a/src/java/org/apache/cassandra/db/partitions/AbstractThreadUnsafePartition.java +++ b/src/java/org/apache/cassandra/db/partitions/AbstractThreadUnsafePartition.java @@ -325,11 +325,17 @@ public abstract class AbstractThreadUnsafePartition implements Partition, Iterab // Note that because a Slice.Bound can never sort equally to a Clustering, we know none of the search will // be a match, so we save from testing for it. - final int start = -search(slice.start(), nextIdx, rows.size()) - 1; // First index to include + // since the binary search starts from nextIdx, the position returned will be an offset from nextIdx; to + // get an absolute position, add nextIdx back in + int searchResult = search(slice.start(), nextIdx, rows.size()); + final int start = nextIdx + (-searchResult - 1); // First index to include + if (start >= rows.size()) return Collections.emptyIterator(); - final int end = -search(slice.end(), start, rows.size()) - 1; // First index to exclude + // similarly, add start to the returned position + searchResult = search(slice.end(), start, rows.size()); + final int end = start + (-searchResult - 1); // First index to exclude // Remember the end to speed up potential further slice search nextIdx = end;
