Cassandra 3.x触发列值 [英] Cassandra 3.x trigger column values

查看:138
本文介绍了Cassandra 3.x触发列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用3.4 Cassandra触发器API,该API引入了修改后的ITrigger接口,例如: https://github.com/apache/cassandra/blob/trunk/examples/triggers/src/org/apache/cassandra/triggers/AuditTrigger.java

I'm using the 3.4 Cassandra trigger API, that introduced the modified ITrigger interface, example: https://github.com/apache/cassandra/blob/trunk/examples/triggers/src/org/apache/cassandra/triggers/AuditTrigger.java

我的问题是从分区对象中提取列值以进行插入/更新语句的方法是什么?如果是,我该怎么做?

My question is what is the way to extract the column values from Partition object for insert/update statements? If so how can I do this?

public interface ITrigger
{
    public Collection<Mutation> augment(Partition update);
}

某些代码段会很有用。

推荐答案

我将此代码用于静态列

@Override
public Collection<Mutation> augment(Partition update) {
    String keyspaceName = update.metadata().ksName;
    //for static columns
    Row dataRow = update.getRow(Clustering.STATIC_CLUSTERING);
    for (Cell cell : dataRow.cells()) {
        ColumnDefinition cDefinition = cell.column();
        String colName = cDefinition.name.toString();
        ByteBuffer value = cell.value();
    }
    return Collections.EMPTY_LIST;
}

colName和value变量是单元格的数据。

The colName and value variables are data of cell.

这篇关于Cassandra 3.x触发列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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