use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class DynamicCompositeTypeTest method testFullRound.
@Test
public void testFullRound() throws Exception {
Table table = Table.open("Keyspace1");
ColumnFamilyStore cfs = table.getColumnFamilyStore(cfName);
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");
RowMutation rm = new RowMutation("Keyspace1", key);
addColumn(rm, cname5);
addColumn(rm, cname1);
addColumn(rm, cname4);
addColumn(rm, cname2);
addColumn(rm, cname3);
rm.apply();
ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("k"), new QueryPath(cfName, null, null)));
Iterator<IColumn> iter = cf.getSortedColumns().iterator();
assert iter.next().name().equals(cname1);
assert iter.next().name().equals(cname2);
assert iter.next().name().equals(cname3);
assert iter.next().name().equals(cname4);
assert iter.next().name().equals(cname5);
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class RowMutation method convertToPending.
@Override
public PendingTransactionMutation convertToPending(long pendingTime, long transactionId) {
PendingTransactionMutation pendingMutation = new PendingTransactionMutation(this.table_, this.key_, pendingTime, transactionId);
for (ColumnFamily columnFamily : modifications_.values()) {
String columnFamilyName = columnFamily.metadata().cfName;
for (IColumn column : columnFamily.columns) {
if (column instanceof SuperColumn) {
if (column.getSubColumns().size() == 0) {
// just inserting a new super column
QueryPath path = new QueryPath(columnFamilyName, column.name(), null);
pendingMutation.makePending(path);
} else {
for (IColumn subcolumn : column.getSubColumns()) {
QueryPath path = new QueryPath(columnFamilyName, column.name(), subcolumn.name());
pendingMutation.makePending(path);
}
}
} else if (column instanceof DeletedColumn) {
assert column.getSubColumns().size() == 0 : "Haven't added support for deleting supercolumn in transactions yet";
QueryPath path = new QueryPath(columnFamilyName, null, column.name());
pendingMutation.makePending(path);
} else {
assert column instanceof Column;
QueryPath path = new QueryPath(columnFamilyName, null, column.name());
pendingMutation.makePending(path);
}
}
}
return pendingMutation;
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class SystemTable method getOldLocalNodeIds.
public static List<NodeId.NodeIdRecord> getOldLocalNodeIds() {
List<NodeId.NodeIdRecord> l = new ArrayList<NodeId.NodeIdRecord>();
Table table = Table.open(Table.SYSTEM_TABLE);
QueryFilter filter = QueryFilter.getIdentityFilter(decorate(ALL_LOCAL_NODE_ID_KEY), new QueryPath(NODE_ID_CF));
ColumnFamily cf = table.getColumnFamilyStore(NODE_ID_CF).getColumnFamily(filter);
NodeId previous = null;
for (IColumn c : cf) {
if (previous != null)
l.add(new NodeId.NodeIdRecord(previous, c.timestamp()));
// this will ignore the last column on purpose since it is the
// current local node id
previous = NodeId.wrap(c.name());
}
return l;
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class SystemTable method getSavedToken.
public static Token getSavedToken() {
Table table = Table.open(Table.SYSTEM_TABLE);
QueryFilter filter = QueryFilter.getNamesFilter(decorate(LOCATION_KEY), new QueryPath(STATUS_CF), TOKEN);
ColumnFamily cf = table.getColumnFamilyStore(STATUS_CF).getColumnFamily(filter);
return cf == null ? null : StorageService.getPartitioner().getTokenFactory().fromByteArray(cf.getColumn(TOKEN).value());
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class SystemTable method incrementAndGetGeneration.
public static int incrementAndGetGeneration() throws IOException {
Table table = Table.open(Table.SYSTEM_TABLE);
QueryFilter filter = QueryFilter.getNamesFilter(decorate(LOCATION_KEY), new QueryPath(STATUS_CF), GENERATION);
ColumnFamily cf = table.getColumnFamilyStore(STATUS_CF).getColumnFamily(filter);
int generation;
if (cf == null) {
// seconds-since-epoch isn't a foolproof new generation
// (where foolproof is "guaranteed to be larger than the last one seen at this ip address"),
// but it's as close as sanely possible
generation = (int) (System.currentTimeMillis() / 1000);
} else {
// Other nodes will ignore gossip messages about a node that have a lower generation than previously seen.
final int storedGeneration = ByteBufferUtil.toInt(cf.getColumn(GENERATION).value()) + 1;
final int now = (int) (System.currentTimeMillis() / 1000);
if (storedGeneration >= now) {
logger.warn("Using stored Gossip Generation {} as it is greater than current system time {}. See CASSANDRA-3654 if you experience problems", storedGeneration, now);
generation = storedGeneration;
} else {
generation = now;
}
}
RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, LOCATION_KEY);
cf = ColumnFamily.create(Table.SYSTEM_TABLE, SystemTable.STATUS_CF);
cf.addColumn(new Column(GENERATION, ByteBufferUtil.bytes(generation), LamportClock.getVersion()));
rm.add(cf);
rm.apply();
forceBlockingFlush(STATUS_CF);
return generation;
}
Aggregations