Search in sources :

Example 1 with Unfiltered

use of org.apache.cassandra.spark.shaded.fourzero.cassandra.db.rows.Unfiltered in project spark-cassandra-bulkreader by jberragan.

the class SSTableReaderTests method countAndValidateRows.

private static int countAndValidateRows(@NotNull final FourZeroSSTableReader reader) {
    final ISSTableScanner scanner = reader.getScanner();
    int count = 0;
    while (scanner.hasNext()) {
        final UnfilteredRowIterator it = scanner.next();
        while (it.hasNext()) {
            final BufferDecoratedKey key = (BufferDecoratedKey) it.partitionKey();
            final int a = key.getKey().asIntBuffer().get();
            final Unfiltered unfiltered = it.next();
            assertTrue(unfiltered.isRow());
            final AbstractRow row = (AbstractRow) unfiltered;
            final int b = row.clustering().bufferAt(0).asIntBuffer().get();
            for (final ColumnData data : row) {
                final Cell cell = (Cell) data;
                final int c = cell.buffer().getInt();
                assertEquals(c, a + b);
                count++;
            }
        }
    }
    return count;
}
Also used : ISSTableScanner(org.apache.cassandra.spark.shaded.fourzero.cassandra.io.sstable.ISSTableScanner) UnfilteredRowIterator(org.apache.cassandra.spark.shaded.fourzero.cassandra.db.rows.UnfilteredRowIterator) AbstractRow(org.apache.cassandra.spark.shaded.fourzero.cassandra.db.rows.AbstractRow) BufferDecoratedKey(org.apache.cassandra.spark.shaded.fourzero.cassandra.db.BufferDecoratedKey) ColumnData(org.apache.cassandra.spark.shaded.fourzero.cassandra.db.rows.ColumnData) Cell(org.apache.cassandra.spark.shaded.fourzero.cassandra.db.rows.Cell) Unfiltered(org.apache.cassandra.spark.shaded.fourzero.cassandra.db.rows.Unfiltered)

Aggregations

BufferDecoratedKey (org.apache.cassandra.spark.shaded.fourzero.cassandra.db.BufferDecoratedKey)1 AbstractRow (org.apache.cassandra.spark.shaded.fourzero.cassandra.db.rows.AbstractRow)1 Cell (org.apache.cassandra.spark.shaded.fourzero.cassandra.db.rows.Cell)1 ColumnData (org.apache.cassandra.spark.shaded.fourzero.cassandra.db.rows.ColumnData)1 Unfiltered (org.apache.cassandra.spark.shaded.fourzero.cassandra.db.rows.Unfiltered)1 UnfilteredRowIterator (org.apache.cassandra.spark.shaded.fourzero.cassandra.db.rows.UnfilteredRowIterator)1 ISSTableScanner (org.apache.cassandra.spark.shaded.fourzero.cassandra.io.sstable.ISSTableScanner)1