我正在通过cassandra中的触发器实现。我想实现触发器,以便使用已修改的表的旧值更新表。假设我在 keyspace keyspace1 中有一个表说 test_table。我还有一个表,说 table_track 在同一个键空间中,列 columnname 和 columnvalue。现在,当在 test_table 中更新一行时,我想将行数据(在执行更新查询之前的 test_table 中)分别填充到列 columnname 和 columnvalue 中。
我在任何地方都找不到有关 cassandra 触发器的任何适当文档。我设法以某种方式实现 InvertedIndex 和一些小例子
public Collection<Mutation> augment(ByteBuffer key, ColumnFamily update)
{
List<Mutation> mutations = new ArrayList<Mutation>(update.getColumnCount());
for (Cell cell : update)
{
// Skip the row marker and other empty values, since they lead to an empty key.
if (cell.value().remaining() > 0)
{
Mutation mutation = new Mutation(properties.getProperty("keyspace"), cell.value());
mutation.add(properties.getProperty("columnfamily"), cell.name(), key, System.currentTimeMillis());
mutations.add(mutation);
}
}
return mutations;
}
我如何修改增强方法来实现该功能。肿瘤坏死因子