use of org.apache.cassandra.db.rows.BufferCell in project cassandra by apache.
the class CellSpecTest method data.
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() {
TableMetadata table = TableMetadata.builder("testing", "testing").addPartitionKeyColumn("pk", BytesType.instance).build();
byte[] rawBytes = { 0, 1, 2, 3, 4, 5, 6 };
ByteBuffer bbBytes = ByteBuffer.wrap(rawBytes);
NativePool pool = new NativePool(1024, 1024, 1, () -> ImmediateFuture.success(true));
NativeAllocator allocator = pool.newAllocator(null);
OpOrder order = new OpOrder();
List<Cell<?>> tests = new ArrayList<>();
BiConsumer<ColumnMetadata, CellPath> fn = (column, path) -> {
tests.add(new ArrayCell(column, 1234, 1, 1, rawBytes, path));
tests.add(new BufferCell(column, 1234, 1, 1, bbBytes, path));
tests.add(new NativeCell(allocator, order.getCurrent(), column, 1234, 1, 1, bbBytes, path));
};
// simple
fn.accept(ColumnMetadata.regularColumn(table, bytes("simple"), BytesType.instance), null);
// complex
// seems NativeCell does not allow CellPath.TOP, or CellPath.BOTTOM
fn.accept(ColumnMetadata.regularColumn(table, bytes("complex"), ListType.getInstance(BytesType.instance, true)), CellPath.create(bytes(UUIDGen.getTimeUUID())));
return tests.stream().map(a -> new Object[] { a.getClass().getSimpleName() + ":" + (a.path() == null ? "simple" : "complex"), a }).collect(Collectors.toList());
}
use of org.apache.cassandra.db.rows.BufferCell in project cassandra by apache.
the class CounterCellTest method testDigestWithEmptyCells.
@Test
public void testDigestWithEmptyCells() throws Exception {
// For DB-1881
ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore(COUNTER1);
ColumnMetadata emptyColDef = cfs.metadata().getColumn(ByteBufferUtil.bytes("val2"));
BufferCell emptyCell = BufferCell.live(emptyColDef, 0, ByteBuffer.allocate(0));
Row.Builder builder = BTreeRow.unsortedBuilder();
builder.newRow(Clustering.make(AsciiSerializer.instance.serialize("test")));
builder.addCell(emptyCell);
Row row = builder.build();
Digest digest = Digest.forReadResponse();
row.digest(digest);
assertNotNull(digest.digest());
}
use of org.apache.cassandra.db.rows.BufferCell in project cassandra by apache.
the class RowFilterTest method testCQLFilterClose.
@Test
public void testCQLFilterClose() {
// CASSANDRA-15126
TableMetadata metadata = TableMetadata.builder("testks", "testcf").addPartitionKeyColumn("pk", Int32Type.instance).addStaticColumn("s", Int32Type.instance).addRegularColumn("r", Int32Type.instance).build();
ColumnMetadata s = metadata.getColumn(new ColumnIdentifier("s", true));
ColumnMetadata r = metadata.getColumn(new ColumnIdentifier("r", true));
ByteBuffer one = Int32Type.instance.decompose(1);
RowFilter filter = RowFilter.NONE.withNewExpressions(new ArrayList<>());
filter.add(s, Operator.NEQ, one);
AtomicBoolean closed = new AtomicBoolean();
UnfilteredPartitionIterator iter = filter.filter(new SingletonUnfilteredPartitionIterator(new UnfilteredRowIterator() {
public DeletionTime partitionLevelDeletion() {
return null;
}
public EncodingStats stats() {
return null;
}
public TableMetadata metadata() {
return metadata;
}
public boolean isReverseOrder() {
return false;
}
public RegularAndStaticColumns columns() {
return null;
}
public DecoratedKey partitionKey() {
return null;
}
public boolean hasNext() {
return false;
}
public Unfiltered next() {
return null;
}
public Row staticRow() {
return BTreeRow.create(Clustering.STATIC_CLUSTERING, LivenessInfo.EMPTY, Row.Deletion.LIVE, BTree.singleton(new BufferCell(s, 1, Cell.NO_TTL, Cell.NO_DELETION_TIME, one, null)));
}
public void close() {
closed.set(true);
}
}), 1);
Assert.assertFalse(iter.hasNext());
Assert.assertTrue(closed.get());
filter = RowFilter.NONE.withNewExpressions(new ArrayList<>());
filter.add(r, Operator.NEQ, one);
closed.set(false);
iter = filter.filter(new SingletonUnfilteredPartitionIterator(new UnfilteredRowIterator() {
boolean hasNext = true;
public DeletionTime partitionLevelDeletion() {
return null;
}
public EncodingStats stats() {
return null;
}
public TableMetadata metadata() {
return metadata;
}
public boolean isReverseOrder() {
return false;
}
public RegularAndStaticColumns columns() {
return null;
}
public DecoratedKey partitionKey() {
return null;
}
public Row staticRow() {
return Rows.EMPTY_STATIC_ROW;
}
public boolean hasNext() {
boolean r = hasNext;
hasNext = false;
return r;
}
public Unfiltered next() {
return BTreeRow.create(Clustering.EMPTY, LivenessInfo.EMPTY, Row.Deletion.LIVE, BTree.singleton(new BufferCell(r, 1, Cell.NO_TTL, Cell.NO_DELETION_TIME, one, null)));
}
public void close() {
closed.set(true);
}
}), 1);
Assert.assertFalse(iter.hasNext());
Assert.assertTrue(closed.get());
}
Aggregations