目前,mutator似乎只适用于标准cf.还有其他方法可以在super cf的子列上执行incrementCounter吗?
答案 0 :(得分:4)
增加superColumn的计数器的一小段代码
SuperColumns包含字符串键,超名和名称......
String key = "keyOfRow";
String superColumnFamily = "foo";
String superColumnName ="bar";
StringSerializer ss = StringSerializer.get();
// let's insert a couple of counter columns in a superColumn
String columnName1="aaa";
String columnName2="bbb";
List <HCounterColumn<String>> myCounters = new
ArrayList<HCounterColumn<String>>();
myCounters.add(HFactory.createCounterColumn(columnName1, 1L));
myCounters.add(HFactory.createCounterColumn(columnName2, 42L));
Mutator mutator = HFactory.createMutator(keyspace,
StringSerializer.get());
mutator.insertCounter(key,superColumnFamily ,
HFactory.createCounterSuperColumn(superColumnName, myCounters, ss,
ss));
mutator.execute();