我需要你在觸發擴充方法提取列名和值的幫助。卡桑德拉觸發採樣代碼來獲取插入值
表防守力:
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;
}
}
我盡力搜索示例代碼在谷歌。但失敗了。請幫助我提供示例代碼。提前致謝。
什麼是觸發它的插入? (我假設你只是插入'data_key' /'data'和'time')。 –
號我插入所有的數據[插入dy_data(ID,data_key,時間,數據)值(現在的(), 'TX_BYTES:H',1385447412778, '數據'); ] – rameshj