Search in sources :

Example 11 with RowIterator

use of org.apache.cassandra.db.rows.RowIterator in project cassandra by apache.

the class KeyspaceTest method assertRowsInResult.

private static void assertRowsInResult(ColumnFamilyStore cfs, SinglePartitionReadCommand command, int... columnValues) {
    try (ReadExecutionController executionController = command.executionController();
        PartitionIterator iterator = command.executeInternal(executionController)) {
        if (columnValues.length == 0) {
            if (iterator.hasNext())
                fail("Didn't expect any results, but got rows starting with: " + iterator.next().next().toString(cfs.metadata()));
            return;
        }
        try (RowIterator rowIterator = iterator.next()) {
            for (int expected : columnValues) {
                Row row = rowIterator.next();
                Cell cell = row.getCell(cfs.metadata().getColumn(new ColumnIdentifier("c", false)));
                assertEquals(String.format("Expected %s, but got %s", ByteBufferUtil.bytesToHex(ByteBufferUtil.bytes(expected)), ByteBufferUtil.bytesToHex(cell.value())), ByteBufferUtil.bytes(expected), cell.value());
            }
            assertFalse(rowIterator.hasNext());
        }
    }
}
Also used : PartitionIterator(org.apache.cassandra.db.partitions.PartitionIterator) RowIterator(org.apache.cassandra.db.rows.RowIterator) ColumnIdentifier(org.apache.cassandra.cql3.ColumnIdentifier) Row(org.apache.cassandra.db.rows.Row) Cell(org.apache.cassandra.db.rows.Cell)

Aggregations

RowIterator (org.apache.cassandra.db.rows.RowIterator)11 PartitionIterator (org.apache.cassandra.db.partitions.PartitionIterator)6 Row (org.apache.cassandra.db.rows.Row)5 ColumnIdentifier (org.apache.cassandra.cql3.ColumnIdentifier)4 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)4 Cell (org.apache.cassandra.db.rows.Cell)3 ByteBuffer (java.nio.ByteBuffer)2 ColumnFilter (org.apache.cassandra.db.filter.ColumnFilter)2 TableMetadata (org.apache.cassandra.schema.TableMetadata)2 Test (org.junit.Test)2 InetAddress (java.net.InetAddress)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Selection (org.apache.cassandra.cql3.selection.Selection)1 ClusteringIndexFilter (org.apache.cassandra.db.filter.ClusteringIndexFilter)1 ClusteringIndexNamesFilter (org.apache.cassandra.db.filter.ClusteringIndexNamesFilter)1 ClusteringIndexSliceFilter (org.apache.cassandra.db.filter.ClusteringIndexSliceFilter)1 RowFilter (org.apache.cassandra.db.filter.RowFilter)1 FilteredPartition (org.apache.cassandra.db.partitions.FilteredPartition)1 UnfilteredPartitionIterator (org.apache.cassandra.db.partitions.UnfilteredPartitionIterator)1