use of org.apache.cassandra.db.IColumn in project eiger by wlloyd.
the class SSTableImportTest method testImportSimpleCfOldFormat.
@Test
public void testImportSimpleCfOldFormat() throws IOException, URISyntaxException {
// Import JSON to temp SSTable file
String jsonUrl = resourcePath("SimpleCF.oldformat.json");
File tempSS = tempSSTableFile("Keyspace1", "Standard1");
SSTableImport.importJson(jsonUrl, "Keyspace1", "Standard1", tempSS.getPath());
// Verify results
SSTableReader reader = SSTableReader.open(Descriptor.fromFilename(tempSS.getPath()));
QueryFilter qf = QueryFilter.getIdentityFilter(Util.dk("rowA"), new QueryPath("Standard1"));
IColumnIterator iter = qf.getSSTableColumnIterator(reader);
ColumnFamily cf = iter.getColumnFamily();
while (iter.hasNext()) cf.addColumn(iter.next());
assert cf.getColumn(ByteBufferUtil.bytes("colAA")).value().equals(hexToBytes("76616c4141"));
assert !(cf.getColumn(ByteBufferUtil.bytes("colAA")) instanceof DeletedColumn);
IColumn expCol = cf.getColumn(ByteBufferUtil.bytes("colAC"));
assert expCol.value().equals(hexToBytes("76616c4143"));
assert expCol instanceof ExpiringColumn;
assert ((ExpiringColumn) expCol).getTimeToLive() == 42 && expCol.getLocalDeletionTime() == 2000000000;
}
use of org.apache.cassandra.db.IColumn in project eiger by wlloyd.
the class SSTableUtils method assertContentEquals.
public static void assertContentEquals(IColumnIterator lhs, IColumnIterator rhs) throws IOException {
assertEquals(lhs.getKey(), rhs.getKey());
// check metadata
ColumnFamily lcf = lhs.getColumnFamily();
ColumnFamily rcf = rhs.getColumnFamily();
if (lcf == null) {
if (rcf == null)
return;
throw new AssertionError("LHS had no content for " + rhs.getKey());
} else if (rcf == null)
throw new AssertionError("RHS had no content for " + lhs.getKey());
assertEquals(lcf.getMarkedForDeleteAt(), rcf.getMarkedForDeleteAt());
assertEquals(lcf.getLocalDeletionTime(), rcf.getLocalDeletionTime());
// iterate columns
while (lhs.hasNext()) {
IColumn clhs = lhs.next();
assert rhs.hasNext() : "LHS contained more columns than RHS for " + lhs.getKey();
IColumn crhs = rhs.next();
assertEquals("Mismatched columns for " + lhs.getKey(), clhs, crhs);
}
assert !rhs.hasNext() : "RHS contained more columns than LHS for " + lhs.getKey();
}
use of org.apache.cassandra.db.IColumn in project eiger by wlloyd.
the class CassandraStorage method columnToTuple.
private Tuple columnToTuple(ByteBuffer name, IColumn col, CfDef cfDef) throws IOException {
Tuple pair = TupleFactory.getInstance().newTuple(2);
List<AbstractType> marshallers = getDefaultMarshallers(cfDef);
Map<ByteBuffer, AbstractType> validators = getValidatorMap(cfDef);
setTupleValue(pair, 0, marshallers.get(0).compose(name));
if (col instanceof Column) {
// standard
if (validators.get(name) == null)
setTupleValue(pair, 1, marshallers.get(1).compose(col.value()));
else
setTupleValue(pair, 1, validators.get(name).compose(col.value()));
return pair;
}
// super
ArrayList<Tuple> subcols = new ArrayList<Tuple>();
for (IColumn subcol : col.getSubColumns()) subcols.add(columnToTuple(subcol.name(), subcol, cfDef));
pair.set(1, new DefaultDataBag(subcols));
return pair;
}
use of org.apache.cassandra.db.IColumn in project eiger by wlloyd.
the class CompactionsPurgeTest method testCompactionPurgeCachedRow.
@Test
public void testCompactionPurgeCachedRow() throws IOException, ExecutionException, InterruptedException {
CompactionManager.instance.disableAutoCompaction();
String tableName = "RowCacheSpace";
String cfName = "CachedCF";
Table table = Table.open(tableName);
ColumnFamilyStore cfs = table.getColumnFamilyStore(cfName);
DecoratedKey key = Util.dk("key3");
RowMutation rm;
// inserts
rm = new RowMutation(tableName, key.key);
for (int i = 0; i < 10; i++) {
rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
}
rm.apply();
// move the key up in row cache
cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, new QueryPath(cfName)));
// deletes row
rm = new RowMutation(tableName, key.key);
rm.delete(new QueryPath(cfName, null, null), 1);
rm.apply();
// flush and major compact
cfs.forceBlockingFlush();
Util.compactAll(cfs).get();
// re-inserts with timestamp lower than delete
rm = new RowMutation(tableName, key.key);
for (int i = 0; i < 10; i++) {
rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), ByteBufferUtil.EMPTY_BYTE_BUFFER, 0);
}
rm.apply();
// Check that the second insert did went in
ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, new QueryPath(cfName)));
assertEquals(10, cf.getColumnCount());
for (IColumn c : cf) assert !c.isMarkedForDelete();
}
use of org.apache.cassandra.db.IColumn in project eiger by wlloyd.
the class CompactionsPurgeTest method testCompactionPurgeTombstonedRow.
@Test
public void testCompactionPurgeTombstonedRow() throws IOException, ExecutionException, InterruptedException {
CompactionManager.instance.disableAutoCompaction();
String tableName = "Keyspace1";
String cfName = "Standard1";
Table table = Table.open(tableName);
ColumnFamilyStore cfs = table.getColumnFamilyStore(cfName);
DecoratedKey key = Util.dk("key3");
RowMutation rm;
// inserts
rm = new RowMutation(tableName, key.key);
for (int i = 0; i < 10; i++) {
rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), ByteBufferUtil.EMPTY_BYTE_BUFFER, i);
}
rm.apply();
// deletes row with timestamp such that not all columns are deleted
rm = new RowMutation(tableName, key.key);
rm.delete(new QueryPath(cfName, null, null), 4);
rm.apply();
// flush and major compact (with tombstone purging)
cfs.forceBlockingFlush();
Util.compactAll(cfs).get();
// re-inserts with timestamp lower than delete
rm = new RowMutation(tableName, key.key);
for (int i = 0; i < 5; i++) {
rm.add(new QueryPath(cfName, null, ByteBufferUtil.bytes(String.valueOf(i))), ByteBufferUtil.EMPTY_BYTE_BUFFER, i);
}
rm.apply();
// Check that the second insert did went in
ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, new QueryPath(cfName)));
assertEquals(10, cf.getColumnCount());
for (IColumn c : cf) assert !c.isMarkedForDelete();
}
Aggregations