本文整理汇总了Java中org.apache.cassandra.thrift.Mutation.setDeletion方法的典型用法代码示例。如果您正苦于以下问题:Java Mutation.setDeletion方法的具体用法?Java Mutation.setDeletion怎么用?Java Mutation.setDeletion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.thrift.Mutation
的用法示例。
在下文中一共展示了Mutation.setDeletion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.apache.cassandra.thrift.Mutation; //导入方法依赖的package包/类
/**
* delete
*
* @throws Exception
*/
@Test
public void delete() throws Exception {
String KEYSPACE = "mock";
client.set_keyspace(KEYSPACE);
List<Mutation> mutations = new ArrayList<Mutation>();
// <columnFamily,mutations>
Map<String, List<Mutation>> columnfamilyMutaions = new HashMap<String, List<Mutation>>();// keyMutations
// <rowKey,keyMutations>
Map<ByteBuffer, Map<String, List<Mutation>>> rowKeyMutations = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
//
List<ByteBuffer> columns = new ArrayList<ByteBuffer>();
// Add as many supercolumns as you want here
columns.add(ByteBufferHelper.toByteBuffer("grad"));
columns.add(ByteBufferHelper.toByteBuffer("math"));
//
SlicePredicate predicate = new SlicePredicate();
predicate.setColumn_names(columns);
// delete
Deletion deletion = new Deletion();
deletion.setPredicate(predicate);
// timestamp in microseconds
long timestamp = System.nanoTime();
deletion.setTimestamp(timestamp);
Mutation mutation = new Mutation();
mutation.setDeletion(deletion);
mutations.add(mutation);
String COLUMN_FAMILY = "student";
columnfamilyMutaions.put(COLUMN_FAMILY, mutations);
String ROW_KEY = "Jack";
rowKeyMutations.put(ByteBufferHelper.toByteBuffer(ROW_KEY),
columnfamilyMutaions);
// mutation_map, consistency_level
client.batch_mutate(rowKeyMutations, ConsistencyLevel.ONE);
}
示例2: createDeleteColumnMutation
import org.apache.cassandra.thrift.Mutation; //导入方法依赖的package包/类
private static Mutation createDeleteColumnMutation(byte[] colName, long timestamp) {
SlicePredicate slicePred = new SlicePredicate();
slicePred.addToColumn_names(ByteBuffer.wrap(colName));
Deletion deletion = new Deletion();
deletion.setPredicate(slicePred);
deletion.setTimestamp(timestamp);
Mutation mutation = new Mutation();
mutation.setDeletion(deletion);
return mutation;
}