Search in sources :

Example 6 with Cell

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

the class JsonTransformer method serializeColumnData.

private void serializeColumnData(ColumnData cd, LivenessInfo liveInfo) {
    if (cd.column().isSimple()) {
        serializeCell((Cell) cd, liveInfo);
    } else {
        ComplexColumnData complexData = (ComplexColumnData) cd;
        if (!complexData.complexDeletion().isLive()) {
            try {
                objectIndenter.setCompact(true);
                json.writeStartObject();
                json.writeFieldName("name");
                json.writeString(cd.column().name.toCQLString());
                serializeDeletion(complexData.complexDeletion());
                objectIndenter.setCompact(true);
                json.writeEndObject();
                objectIndenter.setCompact(false);
            } catch (IOException e) {
                logger.error("Failure parsing ColumnData.", e);
            }
        }
        for (Cell cell : complexData) {
            serializeCell(cell, liveInfo);
        }
    }
}
Also used : ComplexColumnData(org.apache.cassandra.db.rows.ComplexColumnData) IOException(java.io.IOException) Cell(org.apache.cassandra.db.rows.Cell)

Example 7 with Cell

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

the class SinglePartitionSliceCommandTest method checkForS.

private void checkForS(UnfilteredPartitionIterator pi) {
    Assert.assertTrue(pi.toString(), pi.hasNext());
    UnfilteredRowIterator ri = pi.next();
    Assert.assertTrue(ri.columns().contains(s));
    Row staticRow = ri.staticRow();
    Iterator<Cell> cellIterator = staticRow.cells().iterator();
    Assert.assertTrue(staticRow.toString(metadata, true), cellIterator.hasNext());
    Cell cell = cellIterator.next();
    Assert.assertEquals(s, cell.column());
    Assert.assertEquals(ByteBufferUtil.bytesToHex(cell.value()), ByteBufferUtil.bytes("s"), cell.value());
    Assert.assertFalse(cellIterator.hasNext());
}
Also used : UnfilteredRowIterator(org.apache.cassandra.db.rows.UnfilteredRowIterator) Row(org.apache.cassandra.db.rows.Row) Cell(org.apache.cassandra.db.rows.Cell)

Example 8 with Cell

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

the class NeverPurgeTest method verifyContainsTombstones.

private void verifyContainsTombstones(Collection<SSTableReader> sstables, int expectedTombstoneCount) throws Exception {
    // always run a major compaction before calling this
    assertTrue(sstables.size() == 1);
    SSTableReader sstable = sstables.iterator().next();
    int tombstoneCount = 0;
    try (ISSTableScanner scanner = sstable.getScanner()) {
        while (scanner.hasNext()) {
            try (UnfilteredRowIterator iter = scanner.next()) {
                if (!iter.partitionLevelDeletion().isLive())
                    tombstoneCount++;
                while (iter.hasNext()) {
                    Unfiltered atom = iter.next();
                    if (atom.isRow()) {
                        Row r = (Row) atom;
                        if (!r.deletion().isLive())
                            tombstoneCount++;
                        for (Cell c : r.cells()) if (c.isTombstone())
                            tombstoneCount++;
                    }
                }
            }
        }
    }
    assertEquals(tombstoneCount, expectedTombstoneCount);
}
Also used : ISSTableScanner(org.apache.cassandra.io.sstable.ISSTableScanner) UnfilteredRowIterator(org.apache.cassandra.db.rows.UnfilteredRowIterator) SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) Row(org.apache.cassandra.db.rows.Row) Cell(org.apache.cassandra.db.rows.Cell) Unfiltered(org.apache.cassandra.db.rows.Unfiltered)

Example 9 with Cell

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

the class QueryPagerTest method assertCell.

private void assertCell(Row row, ColumnMetadata column, int value) {
    Cell cell = row.getCell(column);
    assertNotNull(cell);
    assertEquals(value, ByteBufferUtil.toInt(cell.value()));
}
Also used : Cell(org.apache.cassandra.db.rows.Cell)

Example 10 with Cell

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

the class HintsWriteThenReadTest method verifyHints.

private void verifyHints(File directory, HintsDescriptor descriptor) {
    long baseTimestamp = descriptor.timestamp;
    int index = 0;
    try (HintsReader reader = HintsReader.open(new File(directory, descriptor.fileName()))) {
        for (HintsReader.Page page : reader) {
            Iterator<Hint> hints = page.hintsIterator();
            while (hints.hasNext()) {
                Hint hint = hints.next();
                long timestamp = baseTimestamp + index;
                Mutation mutation = hint.mutation;
                assertEquals(timestamp, hint.creationTime);
                assertEquals(dk(bytes(index)), mutation.key());
                Row row = mutation.getPartitionUpdates().iterator().next().iterator().next();
                assertEquals(1, Iterables.size(row.cells()));
                assertEquals(bytes(index), row.clustering().get(0));
                Cell cell = row.cells().iterator().next();
                assertNotNull(cell);
                assertEquals(bytes(index), cell.value());
                assertEquals(timestamp * 1000, cell.timestamp());
                index++;
            }
        }
    }
    assertEquals(index, HINTS_COUNT);
}
Also used : Mutation(org.apache.cassandra.db.Mutation) Row(org.apache.cassandra.db.rows.Row) File(java.io.File) Cell(org.apache.cassandra.db.rows.Cell)

Aggregations

Cell (org.apache.cassandra.db.rows.Cell)17 Row (org.apache.cassandra.db.rows.Row)8 ByteBuffer (java.nio.ByteBuffer)6 Test (org.junit.Test)6 ColumnIdentifier (org.apache.cassandra.cql3.ColumnIdentifier)4 BufferCell (org.apache.cassandra.db.rows.BufferCell)4 PartitionIterator (org.apache.cassandra.db.partitions.PartitionIterator)3 RowIterator (org.apache.cassandra.db.rows.RowIterator)3 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)3 ContextState (org.apache.cassandra.db.context.CounterContext.ContextState)2 UnfilteredRowIterator (org.apache.cassandra.db.rows.UnfilteredRowIterator)2 File (java.io.File)1 IOException (java.io.IOException)1 MessageDigest (java.security.MessageDigest)1 CRC32 (java.util.zip.CRC32)1 Mutation (org.apache.cassandra.db.Mutation)1 CounterContext (org.apache.cassandra.db.context.CounterContext)1 CollectionType (org.apache.cassandra.db.marshal.CollectionType)1 CompositeType (org.apache.cassandra.db.marshal.CompositeType)1 ComplexColumnData (org.apache.cassandra.db.rows.ComplexColumnData)1