Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
Expand Down Expand Up @@ -365,6 +366,17 @@ public UnfilteredRowIterator computeNext()
return key;
}

private boolean isEqualToLastKey(PrimaryKey key)
{
// We don't want key.equals(lastKey) because some PrimaryKey implementations consider more than just
// partition key and clustering for equality. This can break lastKey skipping, which is necessary for
// correctness when PrimaryKey doesn't have a clustering (as otherwise, the same partition may get
// filtered and considered as a result multiple times).
return lastKey != null &&
Objects.equals(lastKey.partitionKey(), key.partitionKey()) &&
Objects.equals(lastKey.clustering(), key.clustering());
}

private void fillNextSelectedKeysInPartition(DecoratedKey partitionKey, List<PrimaryKey> nextPrimaryKeys)
{
while (operation.hasNext()
Expand All @@ -376,7 +388,7 @@ private void fillNextSelectedKeysInPartition(DecoratedKey partitionKey, List<Pri
if (key == null)
break;

if (!controller.selects(key) || key.equals(lastKey))
if (!controller.selects(key) || isEqualToLastKey(key))
continue;

nextPrimaryKeys.add(key);
Expand Down Expand Up @@ -405,7 +417,7 @@ private List<PrimaryKey> nextSelectedKeysInRange()
if (firstKey == null)
return Collections.emptyList();
}
while (!controller.selects(firstKey) || firstKey.equals(lastKey));
while (!controller.selects(firstKey) || isEqualToLastKey(firstKey));

lastKey = firstKey;
threadLocalNextKeys.add(firstKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ public void testLargePartition() throws Throwable
}
}

beforeAndAfterFlush( () -> {
// Compaction produces sstables differently than flush, so it is necessary to test sstables written by
// compaction as well. (For example, AA indexes are written as if they were row aware in compaction, but not
// when flushed from the memtable, and that produced the bug fixed in this commit.)
runThenFlushThenCompact( () -> {

// test filtering with single partition queries
int numExpectedRows = LARGE_PARTITION_SIZE / 2;
Expand Down