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);
}
}
}
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());
}
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);
}
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()));
}
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);
}
Aggregations