Cassandra 示例触发器获取已删除的行和列值 [英] Cassandra sample trigger to get the deleted row and column values

查看:26
本文介绍了Cassandra 示例触发器获取已删除的行和列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ITrigger 扩充方法在列族中有更新时被调用.我们如何知道更新操作是插入还是删除?

ITrigger augment method is invoked when there is update in a column family. How do we know if the update operation is insert or delete?

此外,是否可以在触发器实现的同一键空间中的其他表中执行任何 DML 语句?假设有两个表 test1 和 test2.触发器是为 test1 创建的.如果test1有delete操作,我们如何在触发器实现中为test2执行DML语句?

Also, is it possible to execute any DML statements in other tables in the same keyspace in the trigger implementation? Assume that there are two tables test1 and test2. Trigger is created for test1. If there is any delete operation in test1, how do we execute DML statements for test2 in the trigger implementation?

推荐答案

这里是检查更新操作是删除还是插入的代码

Here is the code to check the update operation is delete or insert

@Override
public Collection<Mutation> augment(ByteBuffer key, ColumnFamily update) {
    if (!update.deletionInfo().isLive()) {
        System.out.println("Delete Operation");
    } else {
        System.out.println("Insert Operation");
    }
}

这篇关于Cassandra 示例触发器获取已删除的行和列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆