当前位置: 首页>>代码示例>>Java>>正文


Java Mutation.setDeletion方法代码示例

本文整理汇总了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);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:45,代码来源:CassandraThriftDMLTest.java

示例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;
}
 
开发者ID:QSFT,项目名称:Doradus,代码行数:13,代码来源:CassandraTransaction.java


注:本文中的org.apache.cassandra.thrift.Mutation.setDeletion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。