use of org.apache.cassandra.db.partitions.FilteredPartition in project cassandra by apache.
the class QueryPagerTest method rangeNamesQueryTest.
public void rangeNamesQueryTest(boolean testPagingState, ProtocolVersion protocolVersion) throws Exception {
ReadCommand command = rangeNamesQuery("k0", "k5", 100, "c1", "c4", "c8");
QueryPager pager = command.getPager(null, protocolVersion);
assertFalse(pager.isExhausted());
List<FilteredPartition> partitions = query(pager, 3 * 3);
for (int i = 1; i <= 3; i++) assertRow(partitions.get(i - 1), "k" + i, "c1", "c4", "c8");
assertFalse(pager.isExhausted());
pager = maybeRecreate(pager, command, testPagingState, protocolVersion);
assertFalse(pager.isExhausted());
partitions = query(pager, 3 * 3, 2 * 3);
for (int i = 4; i <= 5; i++) assertRow(partitions.get(i - 4), "k" + i, "c1", "c4", "c8");
assertTrue(pager.isExhausted());
}
use of org.apache.cassandra.db.partitions.FilteredPartition in project cassandra by apache.
the class QueryPagerTest method query.
private static List<FilteredPartition> query(QueryPager pager, int toQuery, int expectedSize) {
StringBuilder sb = new StringBuilder();
List<FilteredPartition> partitionList = new ArrayList<>();
int rows = 0;
try (ReadExecutionController executionController = pager.executionController();
PartitionIterator iterator = pager.fetchPageInternal(toQuery, executionController)) {
while (iterator.hasNext()) {
try (RowIterator rowIter = iterator.next()) {
FilteredPartition partition = FilteredPartition.create(rowIter);
sb.append(partition);
partitionList.add(partition);
rows += partition.rowCount();
}
}
}
assertEquals(sb.toString(), expectedSize, rows);
return partitionList;
}
use of org.apache.cassandra.db.partitions.FilteredPartition in project cassandra by apache.
the class QueryPagerTest method multiQueryTest.
public void multiQueryTest(boolean testPagingState, ProtocolVersion protocolVersion) throws Exception {
ReadQuery command = new SinglePartitionReadCommand.Group(new ArrayList<SinglePartitionReadCommand>() {
{
add(sliceQuery("k1", "c2", "c6", 10));
add(sliceQuery("k4", "c3", "c5", 10));
}
}, DataLimits.NONE);
QueryPager pager = command.getPager(null, protocolVersion);
assertFalse(pager.isExhausted());
List<FilteredPartition> partition = query(pager, 3);
assertRow(partition.get(0), "k1", "c2", "c3", "c4");
assertFalse(pager.isExhausted());
pager = maybeRecreate(pager, command, testPagingState, protocolVersion);
assertFalse(pager.isExhausted());
partition = query(pager, 4);
assertRow(partition.get(0), "k1", "c5", "c6");
assertRow(partition.get(1), "k4", "c3", "c4");
assertFalse(pager.isExhausted());
pager = maybeRecreate(pager, command, testPagingState, protocolVersion);
assertFalse(pager.isExhausted());
partition = query(pager, 3, 1);
assertRow(partition.get(0), "k4", "c5");
assertTrue(pager.isExhausted());
}
use of org.apache.cassandra.db.partitions.FilteredPartition in project cassandra by apache.
the class QueryPagerTest method reversedSliceQueryTest.
public void reversedSliceQueryTest(boolean testPagingState, ProtocolVersion protocolVersion) throws Exception {
ReadCommand command = sliceQuery("k0", "c1", "c8", true, 10);
QueryPager pager = command.getPager(null, protocolVersion);
assertFalse(pager.isExhausted());
List<FilteredPartition> partition = query(pager, 3);
assertRow(partition.get(0), "k0", "c6", "c7", "c8");
assertFalse(pager.isExhausted());
pager = maybeRecreate(pager, command, testPagingState, protocolVersion);
assertFalse(pager.isExhausted());
partition = query(pager, 3);
assertRow(partition.get(0), "k0", "c3", "c4", "c5");
assertFalse(pager.isExhausted());
pager = maybeRecreate(pager, command, testPagingState, protocolVersion);
assertFalse(pager.isExhausted());
partition = query(pager, 3, 2);
assertRow(partition.get(0), "k0", "c1", "c2");
assertTrue(pager.isExhausted());
}
Aggregations