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

查看:1166
本文介绍了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中有任何删除操作,我们如何在触发器实现中为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天全站免登陆