我在一个键空间中有两个列族。这些列族具有相同的模式和数据。当对第一个执行删除操作时,我想删除具有相同主键的第二行。
这是我尝试过的ITrigger扩充方法

@Override
public Collection<Mutation> augment(ByteBuffer key, ColumnFamily update) {
    List<Mutation> mutations = new ArrayList<>(update.getColumnCount());
    String indexKeySpace = properties.getProperty("keyspace");
    String indexColumnFamily = properties.getProperty("table");
    if (!update.deletionInfo().isLive()) {
        Mutation mutation = new Mutation(indexKeySpace, key);
        mutation.delete(indexColumnFamily, System.currentTimeMillis());
        mutations.add(mutation);
    }
    return mutations;
}

最佳答案

我修复它:D
这是工作代码

@Override
public Collection<Mutation> augment(ByteBuffer key, ColumnFamily update) {
    List<Mutation> mutations = new ArrayList<>(update.getColumnCount());
    String indexKeySpace = properties.getProperty("keyspace");
    String indexColumnFamily = properties.getProperty("table");
    if (!update.deletionInfo().isLive()) {
        CFMetaData cfMetaData = Schema.instance.getCFMetaData(indexKeySpace, indexColumnFamily);
        for (ColumnDefinition columnDefinition : cfMetaData.allColumns()) {
            Mutation mutation = new Mutation(indexKeySpace, key);
            mutation.delete(indexColumnFamily, CellNames.simpleSparse(columnDefinition.name), System.currentTimeMillis());
            mutations.add(mutation);
        }
    }
    return mutations;
}

10-06 12:43