use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class CassandraServer method internal_insert.
private void internal_insert(ByteBuffer key, ColumnParent column_parent, Column column, ConsistencyLevel consistency_level, Set<Dep> deps) throws InvalidRequestException, UnavailableException, TimedOutException {
state().hasColumnFamilyAccess(column_parent.column_family, Permission.WRITE);
CFMetaData metadata = ThriftValidation.validateColumnFamily(state().getKeyspace(), column_parent.column_family, false);
ThriftValidation.validateKey(metadata, key);
ThriftValidation.validateColumnParent(metadata, column_parent);
// SuperColumn field is usually optional, but not when we're inserting
if (metadata.cfType == ColumnFamilyType.Super && column_parent.super_column == null) {
throw new InvalidRequestException("missing mandatory super column name for super CF " + column_parent.column_family);
}
ThriftValidation.validateColumnNames(metadata, column_parent, Arrays.asList(column.name));
ThriftValidation.validateColumnData(metadata, column, column_parent.super_column != null);
// be 0 when sent to us, and we'll set it here.
if (column.timestamp == 0) {
column.timestamp = LamportClock.getVersion();
logger.debug("Setting timestamp to {}", column.timestamp);
}
Set<Dependency> dependencies = new HashSet<Dependency>();
for (Dep dep : deps) {
dependencies.add(new Dependency(dep));
}
RowMutation rm = new RowMutation(state().getKeyspace(), key, dependencies);
try {
rm.add(new QueryPath(column_parent.column_family, column_parent.super_column, column.name), column.value, column.timestamp, column.ttl);
} catch (MarshalException e) {
throw new InvalidRequestException(e.getMessage());
}
doInsert(consistency_level, Arrays.asList(rm));
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class CassandraServer method internal_remove.
private long internal_remove(ByteBuffer key, ColumnPath column_path, long timestamp, ConsistencyLevel consistency_level, Set<Dep> deps, boolean isCommutativeOp) throws InvalidRequestException, UnavailableException, TimedOutException {
state().hasColumnFamilyAccess(column_path.column_family, Permission.WRITE);
CFMetaData metadata = ThriftValidation.validateColumnFamily(state().getKeyspace(), column_path.column_family, isCommutativeOp);
ThriftValidation.validateKey(metadata, key);
ThriftValidation.validateColumnPathOrParent(metadata, column_path);
if (isCommutativeOp)
ThriftValidation.validateCommutativeForWrite(metadata, consistency_level);
// be 0 when sent to us, and we'll set it here.
if (timestamp == 0) {
timestamp = LamportClock.getVersion();
logger.debug("Setting timestamp to {}", timestamp);
}
Set<Dependency> dependencies = new HashSet<Dependency>();
for (Dep dep : deps) {
dependencies.add(new Dependency(dep));
}
RowMutation rm = new RowMutation(state().getKeyspace(), key, dependencies);
rm.delete(new QueryPath(column_path), timestamp);
if (isCommutativeOp)
doInsert(consistency_level, Arrays.asList(new CounterMutation(rm, consistency_level)));
else
doInsert(consistency_level, Arrays.asList(rm));
return timestamp;
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class CassandraServer method add.
// counter methods
@Override
public WriteResult add(ByteBuffer key, ColumnParent column_parent, CounterColumn column, ConsistencyLevel consistency_level, Set<Dep> deps, long lts) throws InvalidRequestException, UnavailableException, TimedOutException, TException {
LamportClock.updateTime(lts);
logger.debug("add");
state().hasColumnFamilyAccess(column_parent.column_family, Permission.WRITE);
String keyspace = state().getKeyspace();
CFMetaData metadata = ThriftValidation.validateColumnFamily(keyspace, column_parent.column_family, true);
ThriftValidation.validateKey(metadata, key);
ThriftValidation.validateCommutativeForWrite(metadata, consistency_level);
ThriftValidation.validateColumnParent(metadata, column_parent);
// SuperColumn field is usually optional, but not when we're adding
if (metadata.cfType == ColumnFamilyType.Super && column_parent.super_column == null) {
throw new InvalidRequestException("missing mandatory super column name for super CF " + column_parent.column_family);
}
ThriftValidation.validateColumnNames(metadata, column_parent, Arrays.asList(column.name));
Set<Dependency> dependencies = new HashSet<Dependency>();
for (Dep dep : deps) {
dependencies.add(new Dependency(dep));
}
//add operations also need a dependency on the previous value for this datacenter
try {
ColumnOrSuperColumn cosc = this.internal_get(key, new ColumnPath(column_parent.column_family).setSuper_column(column_parent.super_column).setColumn(column.name), ConsistencyLevel.ONE);
if (cosc.isSetColumn()) {
//on that delete because clients have to wait until it reaches all nodes before resurrecting it
assert cosc.column.isSetDeleted_time();
} else {
ClientContext tmpContext = new ClientContext();
tmpContext.addDep(key, cosc);
if (tmpContext.getDeps().size() > 0) {
Dependency newDep = new Dependency(tmpContext.getDeps().iterator().next());
dependencies.add(newDep);
logger.debug("Adding a dependency on the previous value from this dc: " + newDep);
}
}
} catch (NotFoundException e1) {
//this is fine, it's the first add for this datacenter, no dep needed
}
RowMutation rm = new RowMutation(keyspace, key, dependencies);
long timestamp = LamportClock.getVersion();
try {
rm.addCounter(new QueryPath(column_parent.column_family, column_parent.super_column, column.name), column.value, timestamp, timestamp, null);
} catch (MarshalException e) {
throw new InvalidRequestException(e.getMessage());
}
doInsert(consistency_level, Arrays.asList(new CounterMutation(rm, consistency_level)));
if (logger.isTraceEnabled()) {
logger.trace("add({}, {}, {}, {}, {}, {}) = {}", new Object[] { ByteBufferUtil.bytesToHex(key), column_parent, column, consistency_level, deps, lts, timestamp });
}
return new WriteResult(timestamp, LamportClock.sendTimestamp());
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class CleanupTest method fillCF.
protected void fillCF(ColumnFamilyStore cfs, int rowsPerSSTable) throws ExecutionException, InterruptedException, IOException {
CompactionManager.instance.disableAutoCompaction();
for (int i = 0; i < rowsPerSSTable; i++) {
String key = String.valueOf(i);
// create a row and update the birthdate value, test that the index query fetches the new version
RowMutation rm;
rm = new RowMutation(TABLE1, ByteBufferUtil.bytes(key));
rm.add(new QueryPath(cfs.getColumnFamilyName(), null, COLUMN), VALUE, System.currentTimeMillis());
rm.applyUnsafe();
}
cfs.forceBlockingFlush();
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class CommitLogTest method testExceedSegmentSizeWithOverhead.
// CASSANDRA-3615
@Test
public void testExceedSegmentSizeWithOverhead() throws Exception {
CommitLog.instance.resetUnsafe();
RowMutation rm = new RowMutation("Keyspace1", bytes("k"));
rm.add(new QueryPath("Standard1", null, bytes("c1")), ByteBuffer.allocate((128 * 1024 * 1024) - 83), 0);
CommitLog.instance.add(rm);
}
Aggregations