use of org.apache.cassandra.cql3.FieldIdentifier in project cassandra by apache.
the class CellTest method testValidateNonFrozenUDT.
@Test
public void testValidateNonFrozenUDT() {
// has field position 0
FieldIdentifier f1 = field("f1");
// has field position 1
FieldIdentifier f2 = field("f2");
UserType udt = new UserType("ks", bb("myType"), asList(f1, f2), asList(Int32Type.instance, UTF8Type.instance), true);
ColumnMetadata c;
// Valid cells
c = fakeColumn("c", udt);
assertValid(BufferCell.live(c, 0, bb(1), CellPath.create(bbs(0))));
assertValid(BufferCell.live(c, 0, bb("foo"), CellPath.create(bbs(1))));
assertValid(BufferCell.expiring(c, 0, 4, 4, bb(1), CellPath.create(bbs(0))));
assertValid(BufferCell.expiring(c, 0, 4, 4, bb("foo"), CellPath.create(bbs(1))));
assertValid(BufferCell.tombstone(c, 0, 4, CellPath.create(bbs(0))));
// Invalid value (text in an int field)
assertInvalid(BufferCell.live(c, 0, bb("foo"), CellPath.create(bbs(0))));
// Invalid ttl
assertInvalid(BufferCell.expiring(c, 0, -4, 4, bb(1), CellPath.create(bbs(0))));
// Invalid local deletion times
assertInvalid(BufferCell.expiring(c, 0, 4, -5, bb(1), CellPath.create(bbs(0))));
assertInvalid(BufferCell.expiring(c, 0, 4, Cell.NO_DELETION_TIME, bb(1), CellPath.create(bbs(0))));
// Invalid cell path (int values should be 0 or 2 bytes)
assertInvalid(BufferCell.live(c, 0, bb(1), CellPath.create(ByteBufferUtil.bytes((long) 4))));
}
use of org.apache.cassandra.cql3.FieldIdentifier in project cassandra by apache.
the class CellTest method testValidateFrozenUDT.
@Test
public void testValidateFrozenUDT() {
// has field position 0
FieldIdentifier f1 = field("f1");
// has field position 1
FieldIdentifier f2 = field("f2");
UserType udt = new UserType("ks", bb("myType"), asList(f1, f2), asList(Int32Type.instance, UTF8Type.instance), false);
ColumnMetadata c = fakeColumn("c", udt);
ByteBuffer val = udt(bb(1), bb("foo"));
// Valid cells
assertValid(BufferCell.live(c, 0, val));
assertValid(BufferCell.live(c, 0, val));
assertValid(BufferCell.expiring(c, 0, 4, 4, val));
assertValid(BufferCell.expiring(c, 0, 4, 4, val));
assertValid(BufferCell.tombstone(c, 0, 4));
// fewer values than types is accepted
assertValid(BufferCell.live(c, 0, udt(bb(1))));
// Invalid values
// invalid types
assertInvalid(BufferCell.live(c, 0, udt(bb("foo"), bb(1))));
// too many types
assertInvalid(BufferCell.live(c, 0, udt(bb(1), bb("foo"), bb("bar"))));
// Invalid ttl
assertInvalid(BufferCell.expiring(c, 0, -4, 4, val));
// Invalid local deletion times
assertInvalid(BufferCell.expiring(c, 0, 4, -5, val));
assertInvalid(BufferCell.expiring(c, 0, 4, Cell.NO_DELETION_TIME, val));
}
Aggregations