gpt4 book ai didi

java - 如何使用 cassandra 触发器执行删除操作?

转载 作者:行者123 更新时间:2023-11-30 08:08:21 25 4
gpt4 key购买 nike

我在一个键空间中有两个列族。这些列族具有相同的模式和数据。当对第一个执行删除操作时,我想删除第二个具有相同主键的行。这是我在 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;
}

最佳答案

我修好了: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;
}

关于java - 如何使用 cassandra 触发器执行删除操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33195289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com