Fix repeated slices on AbstractThreadUnsafePartition.SliceableIterator

Patch by Tyler Hobbs; reviewed by Stefania Alborghetti for CASSANDRA-10002
This commit is contained in:
Tyler Hobbs 2015-08-07 14:19:00 -05:00
parent a8b8515c84
commit e5e2910443
2 changed files with 9 additions and 2 deletions

View File

@ -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)

View File

@ -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;