Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Cassandra在更新另一个表时触发更新_Java_Triggers_Cassandra_Cassandra 2.1 - Fatal编程技术网

Java Cassandra在更新另一个表时触发更新

Java Cassandra在更新另一个表时触发更新,java,triggers,cassandra,cassandra-2.1,Java,Triggers,Cassandra,Cassandra 2.1,我正在研究cassandra中触发器的实现。 我想实现触发器,以便使用已修改表的旧值更新表。 假设我在keyspace keyspace1中有一个表say test_table。 我在同一个键空间中还有一个表say table_track,其中有columnname和columnvalue列。 现在,当在test_表中更新一行时,我想用行数据(在执行更新查询之前的test_表中)分别填充track_表的columnname和columnvalue列 我找不到任何关于卡桑德拉触发器的适当文档。 我

我正在研究cassandra中触发器的实现。 我想实现触发器,以便使用已修改表的旧值更新表。 假设我在keyspace keyspace1中有一个表say test_table。 我在同一个键空间中还有一个表say table_track,其中有columnname和columnvalue列。 现在,当在test_表中更新一行时,我想用行数据(在执行更新查询之前的test_表中)分别填充track_表的columnname和columnvalue列

我找不到任何关于卡桑德拉触发器的适当文档。 我设法以某种方式实现了InvertDindex和一些小示例

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;
}
公共集合扩充(ByteBuffer键,ColumnFamily更新)
{
列表变量=新的ArrayList(update.getColumnCount());
用于(单元格:更新)
{
//跳过行标记和其他空值,因为它们会导致一个空键。
if(cell.value().remaining()>0)
{
突变突变=新突变(properties.getProperty(“keyspace”)、cell.value();
add(properties.getProperty(“columnfamily”)、cell.name()、key、System.currentTimeMillis();
突变。添加(突变);
}
}
返回突变;
}
如何修改augment方法以实现功能。
Tnx

您使用了错误的键来创建突变实例
这是工作代码

public Collection<Mutation> augment(ByteBuffer key, ColumnFamily update) 
{    
    List<Mutation> mutations = new ArrayList<Mutation>(update.getColumnCount());

    for (Cell cell : update)
    {
        if (cell.value().remaining() > 0)
        {
            Mutation mutation = new Mutation(properties.getProperty("keyspace"), key);
            mutation.add(properties.getProperty("columnfamily"), cell.name(), cell.value(), System.currentTimeMillis());
            mutations.add(mutation);
        }
   }
   return mutations;
}
公共集合扩充(ByteBuffer键,ColumnFamily更新)
{    
列表变量=新的ArrayList(update.getColumnCount());
用于(单元格:更新)
{
if(cell.value().remaining()>0)
{
突变=新突变(properties.getProperty(“keyspace”),key);
add(properties.getProperty(“columnfamily”)、cell.name()、cell.value()、System.currentTimeMillis();
突变。添加(突变);
}
}
返回突变;
}