我在一个Key Space中有两个Column Family。这些列族具有相同的模式和数据。当在第一个上执行删除操作时,我想删除具有相同主键的第二行。 以下是我在ITrigger增强方法上所尝试的内容
@Override
public Collection<Mutation> augment(ByteBuffer key, ColumnFamily update) {
List<Mutation> mutations = new ArrayList<>(update.getColumnCount());
String indexKeySpace = properties.getProperty("keyspace");
String indexColumnFamily = properties.getProperty("table");
if (!update.deletionInfo().isLive()) {
Mutation mutation = new Mutation(indexKeySpace, key);
mutation.delete(indexColumnFamily, System.currentTimeMillis());
mutations.add(mutation);
}
return mutations;
}
答案 0 :(得分:3)
我解决了这个问题:D
这是工作代码
@Override
public Collection<Mutation> augment(ByteBuffer key, ColumnFamily update) {
List<Mutation> mutations = new ArrayList<>(update.getColumnCount());
String indexKeySpace = properties.getProperty("keyspace");
String indexColumnFamily = properties.getProperty("table");
if (!update.deletionInfo().isLive()) {
CFMetaData cfMetaData = Schema.instance.getCFMetaData(indexKeySpace, indexColumnFamily);
for (ColumnDefinition columnDefinition : cfMetaData.allColumns()) {
Mutation mutation = new Mutation(indexKeySpace, key);
mutation.delete(indexColumnFamily, CellNames.simpleSparse(columnDefinition.name), System.currentTimeMillis());
mutations.add(mutation);
}
}
return mutations;
}