use of org.apache.cassandra.config.CFMetaData in project eiger by wlloyd.
the class ColumnFamily method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder("ColumnFamily(");
CFMetaData cfm = metadata();
sb.append(cfm == null ? "<anonymous>" : cfm.cfName);
if (isMarkedForDelete())
sb.append(" -deleted at ").append(getMarkedForDeleteAt()).append("-");
sb.append(" [").append(getComparator().getColumnsString(getSortedColumns())).append("])");
return sb.toString();
}
use of org.apache.cassandra.config.CFMetaData in project eiger by wlloyd.
the class RowMutation method toString.
@Override
public String toString(boolean shallow) {
StringBuilder buff = new StringBuilder("RowMutation(");
buff.append("keyspace='").append(table_).append('\'');
buff.append(", key='").append(ByteBufferUtil.bytesToHex(key_)).append('\'');
buff.append(", modifications=[");
if (shallow) {
List<String> cfnames = new ArrayList<String>();
for (Integer cfid : modifications_.keySet()) {
CFMetaData cfm = Schema.instance.getCFMetaData(cfid);
cfnames.add(cfm == null ? "-dropped-" : cfm.cfName);
}
buff.append(StringUtils.join(cfnames, ", "));
} else
buff.append(StringUtils.join(modifications_.values(), ", "));
return buff.append("])").toString();
}
use of org.apache.cassandra.config.CFMetaData in project eiger by wlloyd.
the class ReadCallback method randomlyReadRepair.
private boolean randomlyReadRepair() {
if (resolver instanceof RowDigestResolver) {
assert command instanceof ReadCommand : command;
String table = ((RowDigestResolver) resolver).table;
String columnFamily = ((ReadCommand) command).getColumnFamilyName();
CFMetaData cfmd = Schema.instance.getTableMetaData(table).get(columnFamily);
return cfmd.getReadRepairChance() > FBUtilities.threadLocalRandom().nextDouble();
}
// we don't read repair on range scans
return false;
}
use of org.apache.cassandra.config.CFMetaData in project eiger by wlloyd.
the class DeleteStatement method mutationForKey.
public RowMutation mutationForKey(ByteBuffer key, String keyspace, Long timestamp, ClientState clientState, List<String> variables) throws InvalidRequestException {
RowMutation rm = new RowMutation(keyspace, key);
CFMetaData metadata = validateColumnFamily(keyspace, columnFamily);
QueryProcessor.validateKeyAlias(metadata, keyName);
AbstractType<?> comparator = metadata.getComparatorFor(null);
if (columns.size() < 1) {
// No columns, delete the row
rm.delete(new QueryPath(columnFamily), (timestamp == null) ? getTimestamp(clientState) : timestamp);
} else {
// Delete specific columns
for (Term column : columns) {
ByteBuffer columnName = column.getByteBuffer(comparator, variables);
validateColumnName(columnName);
rm.delete(new QueryPath(columnFamily, null, columnName), (timestamp == null) ? getTimestamp(clientState) : timestamp);
}
}
return rm;
}
use of org.apache.cassandra.config.CFMetaData in project eiger by wlloyd.
the class BatchMutateTransactionUtil method convertToInternalMutations.
public static List<IMutation> convertToInternalMutations(String keyspace, Map<ByteBuffer, Map<String, List<Mutation>>> mutation_map, ByteBuffer coordinatorKey) throws InvalidRequestException {
//the timestamp and localCommitTime are set when we apply the transaction, so we'll set them to invalid values here
long timestamp = Long.MIN_VALUE;
long localCommitTime = Long.MIN_VALUE;
List<IMutation> rowMutations = new ArrayList<IMutation>();
//Note, permission was checked when the thrift interface received the transaction.
for (Map.Entry<ByteBuffer, Map<String, List<Mutation>>> mutationEntry : mutation_map.entrySet()) {
ByteBuffer key = mutationEntry.getKey();
// We need to separate row mutation for standard cf and counter cf (that will be encapsulated in a
// CounterMutation) because it doesn't follow the same code path
RowMutation rmStandard = null;
RowMutation rmCounter = null;
Map<String, List<Mutation>> columnFamilyToMutations = mutationEntry.getValue();
for (Map.Entry<String, List<Mutation>> columnFamilyMutations : columnFamilyToMutations.entrySet()) {
String cfName = columnFamilyMutations.getKey();
CFMetaData metadata = ThriftValidation.validateColumnFamily(keyspace, cfName);
ThriftValidation.validateKey(metadata, key);
RowMutation rm;
if (metadata.getDefaultValidator().isCommutative()) {
ThriftValidation.validateCommutativeForWrite(metadata, ConsistencyLevel.ONE);
rmCounter = rmCounter == null ? new RowMutation(keyspace, key) : rmCounter;
rm = rmCounter;
} else {
rmStandard = rmStandard == null ? new RowMutation(keyspace, key) : rmStandard;
rm = rmStandard;
}
for (Mutation mutation : columnFamilyMutations.getValue()) {
ThriftValidation.validateMutation(metadata, mutation);
if (mutation.deletion != null) {
rm.deleteColumnOrSuperColumn(cfName, mutation.deletion, timestamp, localCommitTime, coordinatorKey);
}
if (mutation.column_or_supercolumn != null) {
rm.addColumnOrSuperColumn(cfName, mutation.column_or_supercolumn, timestamp, localCommitTime, coordinatorKey);
}
}
}
if (rmStandard != null && !rmStandard.isEmpty())
rowMutations.add(rmStandard);
if (rmCounter != null && !rmCounter.isEmpty())
rowMutations.add(new org.apache.cassandra.db.CounterMutation(rmCounter, ConsistencyLevel.ONE));
}
logger.debug("Mutations are {}", rowMutations);
return rowMutations;
}
Aggregations