Search in sources :

Example 6 with FilteredPartition

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());
}
Also used : QueryPager(org.apache.cassandra.service.pager.QueryPager) FilteredPartition(org.apache.cassandra.db.partitions.FilteredPartition)

Example 7 with FilteredPartition

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;
}
Also used : PartitionIterator(org.apache.cassandra.db.partitions.PartitionIterator) RowIterator(org.apache.cassandra.db.rows.RowIterator) FilteredPartition(org.apache.cassandra.db.partitions.FilteredPartition)

Example 8 with FilteredPartition

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());
}
Also used : QueryPager(org.apache.cassandra.service.pager.QueryPager) FilteredPartition(org.apache.cassandra.db.partitions.FilteredPartition)

Example 9 with FilteredPartition

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());
}
Also used : QueryPager(org.apache.cassandra.service.pager.QueryPager) FilteredPartition(org.apache.cassandra.db.partitions.FilteredPartition)

Aggregations

FilteredPartition (org.apache.cassandra.db.partitions.FilteredPartition)9 QueryPager (org.apache.cassandra.service.pager.QueryPager)7 Test (org.junit.Test)3 PartitionIterator (org.apache.cassandra.db.partitions.PartitionIterator)1 Row (org.apache.cassandra.db.rows.Row)1 RowIterator (org.apache.cassandra.db.rows.RowIterator)1 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)1