我实现了cassandra-trigger。因此,每当我在触发器创建的表中执行插入/更新/删除操作时,我的触发器代码就会被调用。
我的要求是,如果要从表中删除任何行,则需要将该行复制到另一个表中。有可能吗?
附加了工作代码以获取事件。
public class App implements ITrigger
{
private static final Logger logger = LoggerFactory.getLogger(App.class);
public Collection<Mutation> augment(Partition update)
{
logger.info("Trigger called !!!");
String auditKeyspace = "keyspace";
String auditTable = "table_name";
CFMetaData metadata = Schema.instance.getCFMetaData(auditKeyspace, auditTable);
logger.info("metadta:: "+metadata.toString());
String tableName = update.metadata().cfName;
logger.info("Table: " + tableName);
logger.info("info::"+update.toString());
logger.info("msggg::"+update.columns());
ByteBuffer key = update.partitionKey().getKey();
return Collections.emptyList();
//return Collections.singletonList(audit.buildAsMutation());
}
}
让我们假设tableA(触发创建的表)和tableB 如果要删除tableA中的一行,则应在tableB中插入同一行。
预先感谢