use of org.apache.cassandra.schema.ColumnMetadata in project cassandra by apache.
the class CommitLogReaderTest method confirmReadOrder.
/**
* Since we have both table and non mixed into the CL, we ignore updates that aren't for the table the test handler
* is configured to check.
* @param handler
* @param offset integer offset of count we expect to see in record
*/
private void confirmReadOrder(TestCLRHandler handler, int offset) {
ColumnMetadata cd = currentTableMetadata().getColumn(new ColumnIdentifier("data", false));
int i = 0;
int j = 0;
while (i + j < handler.seenMutationCount()) {
PartitionUpdate pu = handler.seenMutations.get(i + j).get(currentTableMetadata());
if (pu == null) {
j++;
continue;
}
for (Row r : pu) {
String expected = Integer.toString(i + offset);
String seen = new String(r.getCell(cd).value().array());
if (!expected.equals(seen))
Assert.fail("Mismatch at index: " + i + ". Offset: " + offset + " Expected: " + expected + " Seen: " + seen);
}
i++;
}
}
use of org.apache.cassandra.schema.ColumnMetadata in project cassandra by apache.
the class RowTest method testHashCode.
@Test
public void testHashCode() {
ColumnMetadata defA = metadata.getColumn(new ColumnIdentifier("a", true));
ColumnMetadata defB = metadata.getColumn(new ColumnIdentifier("b", true));
Row.Builder builder = BTreeRow.unsortedBuilder(nowInSeconds);
builder.newRow(metadata.comparator.make("c1"));
writeSimpleCellValue(builder, defA, "a1", 0);
writeSimpleCellValue(builder, defA, "a2", 1);
writeSimpleCellValue(builder, defB, "b1", 1);
Row row = builder.build();
Map<Row, Integer> map = new HashMap<>();
map.put(row, 1);
assertEquals(Integer.valueOf(1), map.get(row));
}
use of org.apache.cassandra.schema.ColumnMetadata in project cassandra by apache.
the class RowTest method testResolve.
@Test
public void testResolve() {
ColumnMetadata defA = metadata.getColumn(new ColumnIdentifier("a", true));
ColumnMetadata defB = metadata.getColumn(new ColumnIdentifier("b", true));
Row.Builder builder = BTreeRow.unsortedBuilder(nowInSeconds);
builder.newRow(metadata.comparator.make("c1"));
writeSimpleCellValue(builder, defA, "a1", 0);
writeSimpleCellValue(builder, defA, "a2", 1);
writeSimpleCellValue(builder, defB, "b1", 1);
Row row = builder.build();
PartitionUpdate update = PartitionUpdate.singleRowUpdate(metadata, dk, row);
Unfiltered unfiltered = update.unfilteredIterator().next();
assertTrue(unfiltered.kind() == Unfiltered.Kind.ROW);
row = (Row) unfiltered;
assertEquals("a2", defA.cellValueType().getString(row.getCell(defA).value()));
assertEquals("b1", defB.cellValueType().getString(row.getCell(defB).value()));
assertEquals(2, row.columns().size());
}
use of org.apache.cassandra.schema.ColumnMetadata in project cassandra by apache.
the class DynamicCompositeTypeTest method testFullRoundReversed.
@Test
public void testFullRoundReversed() throws Exception {
Keyspace keyspace = Keyspace.open(KEYSPACE1);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARDDYNCOMPOSITE);
ByteBuffer cname1 = createDynamicCompositeKey("test1", null, -1, false, true);
ByteBuffer cname2 = createDynamicCompositeKey("test1", uuids[0], 24, false, true);
ByteBuffer cname3 = createDynamicCompositeKey("test1", uuids[0], 42, false, true);
ByteBuffer cname4 = createDynamicCompositeKey("test2", uuids[0], -1, false, true);
ByteBuffer cname5 = createDynamicCompositeKey("test2", uuids[1], 42, false, true);
ByteBuffer key = ByteBufferUtil.bytes("kr");
long ts = FBUtilities.timestampMicros();
new RowUpdateBuilder(cfs.metadata(), ts, key).clustering(cname5).add("val", "cname5").build().applyUnsafe();
new RowUpdateBuilder(cfs.metadata(), ts, key).clustering(cname1).add("val", "cname1").build().applyUnsafe();
new RowUpdateBuilder(cfs.metadata(), ts, key).clustering(cname4).add("val", "cname4").build().applyUnsafe();
new RowUpdateBuilder(cfs.metadata(), ts, key).clustering(cname2).add("val", "cname2").build().applyUnsafe();
new RowUpdateBuilder(cfs.metadata(), ts, key).clustering(cname3).add("val", "cname3").build().applyUnsafe();
ColumnMetadata cdef = cfs.metadata().getColumn(ByteBufferUtil.bytes("val"));
ImmutableBTreePartition readPartition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, key).build());
Iterator<Row> iter = readPartition.iterator();
compareValues(iter.next().getCell(cdef), "cname5");
compareValues(iter.next().getCell(cdef), "cname4");
// null UUID < reversed value
compareValues(iter.next().getCell(cdef), "cname1");
compareValues(iter.next().getCell(cdef), "cname3");
compareValues(iter.next().getCell(cdef), "cname2");
}
use of org.apache.cassandra.schema.ColumnMetadata in project cassandra by apache.
the class DynamicCompositeTypeTest method testFullRound.
@Test
public void testFullRound() throws Exception {
Keyspace keyspace = Keyspace.open(KEYSPACE1);
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARDDYNCOMPOSITE);
ByteBuffer cname1 = createDynamicCompositeKey("test1", null, -1, false);
ByteBuffer cname2 = createDynamicCompositeKey("test1", uuids[0], 24, false);
ByteBuffer cname3 = createDynamicCompositeKey("test1", uuids[0], 42, false);
ByteBuffer cname4 = createDynamicCompositeKey("test2", uuids[0], -1, false);
ByteBuffer cname5 = createDynamicCompositeKey("test2", uuids[1], 42, false);
ByteBuffer key = ByteBufferUtil.bytes("k");
long ts = FBUtilities.timestampMicros();
new RowUpdateBuilder(cfs.metadata(), ts, key).clustering(cname5).add("val", "cname5").build().applyUnsafe();
new RowUpdateBuilder(cfs.metadata(), ts, key).clustering(cname1).add("val", "cname1").build().applyUnsafe();
new RowUpdateBuilder(cfs.metadata(), ts, key).clustering(cname4).add("val", "cname4").build().applyUnsafe();
new RowUpdateBuilder(cfs.metadata(), ts, key).clustering(cname2).add("val", "cname2").build().applyUnsafe();
new RowUpdateBuilder(cfs.metadata(), ts, key).clustering(cname3).add("val", "cname3").build().applyUnsafe();
ColumnMetadata cdef = cfs.metadata().getColumn(ByteBufferUtil.bytes("val"));
ImmutableBTreePartition readPartition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs, key).build());
Iterator<Row> iter = readPartition.iterator();
compareValues(iter.next().getCell(cdef), "cname1");
compareValues(iter.next().getCell(cdef), "cname2");
compareValues(iter.next().getCell(cdef), "cname3");
compareValues(iter.next().getCell(cdef), "cname4");
compareValues(iter.next().getCell(cdef), "cname5");
}
Aggregations