use of org.apache.cassandra.service.pager.QueryPager in project cassandra by apache.
the class QueryPagerTest method queryAndVerifyCells.
private void queryAndVerifyCells(TableMetadata table, boolean reversed, String key) throws Exception {
ClusteringIndexFilter rowfilter = new ClusteringIndexSliceFilter(Slices.ALL, reversed);
ReadCommand command = SinglePartitionReadCommand.create(table, nowInSec, Util.dk(key), ColumnFilter.all(table), rowfilter);
QueryPager pager = command.getPager(null, ProtocolVersion.CURRENT);
ColumnMetadata staticColumn = table.staticColumns().getSimple(0);
assertEquals(staticColumn.name.toCQLString(), "st");
for (int i = 0; i < 5; i++) {
try (ReadExecutionController controller = pager.executionController();
PartitionIterator partitions = pager.fetchPageInternal(1, controller)) {
try (RowIterator partition = partitions.next()) {
assertCell(partition.staticRow(), staticColumn, 4);
Row row = partition.next();
int cellIndex = !reversed ? i : 4 - i;
assertEquals(row.clustering().get(0), ByteBufferUtil.bytes(cellIndex));
assertCell(row, table.getColumn(new ColumnIdentifier("v1", false)), cellIndex);
assertCell(row, table.getColumn(new ColumnIdentifier("v2", false)), cellIndex);
// the partition/page should contain just a single regular row
assertFalse(partition.hasNext());
}
}
}
// After processing the 5 rows there should be no more rows to return
try (ReadExecutionController controller = pager.executionController();
PartitionIterator partitions = pager.fetchPageInternal(1, controller)) {
assertFalse(partitions.hasNext());
}
}
Aggregations