【发布时间】:2016-06-21 23:12:01
【问题描述】:
我需要您的帮助来提取触发器扩充方法中的列名和值。
表定义:
create table dy_data (
id timeuuid,
data_key text,
time timestamp,
data text,primary key((id,data_key),time)
) with clustering order by (time desc);
触发代码:
public class ArchiveTrigger implements ITrigger {
public Collection<RowMutation> augment(ByteBuffer key, ColumnFamily cf) {
try {
// Below loop only has 2 columns ( one is "data" and another one may be "time" but i am not sure, because i cannot get value.
for (Column cell : cf) {
//Got Exception if I try to get column name
String name = ByteBufferUtil.string(cell.name());
//Got only "data" column value and empty value for another column may be "time". If I try ByteBufferUtil.toLong(cell.value()) it throws exception
String value = ByteBufferUtil.string(cell.value());
log(" name = " + name);
log(" value = " + value);
}
} catch (Exception e) {
logger.warn("Exception ", e);
}
return null;
}
}
我尽力在 google 中搜索示例代码。但是失败了。请帮助我提供示例代码。提前致谢。
【问题讨论】:
-
触发它的插入是什么? (我假设您只插入
data_key/data和time)。 -
没有。我插入了所有数据 [ 插入 dy_data(id,data_key,time,data) 值( now(),'TX_BYTES:H',1385447412778,'data') ; ]