Search in sources :

Example 6 with QueryPager

use of org.apache.cassandra.service.pager.QueryPager in project cassandra by apache.

the class QueryPagerTest method sliceQueryTest.

public void sliceQueryTest(boolean testPagingState, ProtocolVersion protocolVersion) throws Exception {
    ReadCommand command = sliceQuery("k0", "c1", "c8", 10);
    QueryPager pager = command.getPager(null, protocolVersion);
    assertFalse(pager.isExhausted());
    List<FilteredPartition> partition = query(pager, 3);
    assertRow(partition.get(0), "k0", "c1", "c2", "c3");
    assertFalse(pager.isExhausted());
    pager = maybeRecreate(pager, command, testPagingState, protocolVersion);
    assertFalse(pager.isExhausted());
    partition = query(pager, 3);
    assertRow(partition.get(0), "k0", "c4", "c5", "c6");
    assertFalse(pager.isExhausted());
    pager = maybeRecreate(pager, command, testPagingState, protocolVersion);
    assertFalse(pager.isExhausted());
    partition = query(pager, 3, 2);
    assertRow(partition.get(0), "k0", "c7", "c8");
    assertTrue(pager.isExhausted());
}
Also used : QueryPager(org.apache.cassandra.service.pager.QueryPager) FilteredPartition(org.apache.cassandra.db.partitions.FilteredPartition)

Example 7 with QueryPager

use of org.apache.cassandra.service.pager.QueryPager in project cassandra by apache.

the class QueryPagerTest method SliceQueryWithTombstoneTest.

@Test
public void SliceQueryWithTombstoneTest() throws Exception {
    // Testing for the bug of #6748
    String keyspace = "cql_keyspace";
    String table = "table2";
    ColumnFamilyStore cfs = Keyspace.open(keyspace).getColumnFamilyStore(table);
    // Insert rows but with a tombstone as last cell
    for (int i = 0; i < 5; i++) executeInternal(String.format("INSERT INTO %s.%s (k, c, v) VALUES ('k%d', 'c%d', null)", keyspace, table, 0, i));
    ReadCommand command = SinglePartitionReadCommand.create(cfs.metadata(), nowInSec, Util.dk("k0"), Slice.ALL);
    QueryPager pager = command.getPager(null, ProtocolVersion.CURRENT);
    for (int i = 0; i < 5; i++) {
        List<FilteredPartition> partitions = query(pager, 1);
        // The only live cell we should have each time is the row marker
        assertRow(partitions.get(0), "k0", "c" + i);
    }
}
Also used : QueryPager(org.apache.cassandra.service.pager.QueryPager) FilteredPartition(org.apache.cassandra.db.partitions.FilteredPartition) Test(org.junit.Test)

Example 8 with QueryPager

use of org.apache.cassandra.service.pager.QueryPager 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 9 with QueryPager

use of org.apache.cassandra.service.pager.QueryPager 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 10 with QueryPager

use of org.apache.cassandra.service.pager.QueryPager 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

QueryPager (org.apache.cassandra.service.pager.QueryPager)11 FilteredPartition (org.apache.cassandra.db.partitions.FilteredPartition)7 PartitionIterator (org.apache.cassandra.db.partitions.PartitionIterator)2 AggregationQueryPager (org.apache.cassandra.service.pager.AggregationQueryPager)2 Test (org.junit.Test)2 ColumnIdentifier (org.apache.cassandra.cql3.ColumnIdentifier)1 Row (org.apache.cassandra.db.rows.Row)1 RowIterator (org.apache.cassandra.db.rows.RowIterator)1 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)1