我有一个具有多个计数器列的列族。现在我想代表不同的行键获取它们的值,例如 RangeSlicesQuery 或 MultigetSliceQuery,我想应用于计数器列,请在计数器列中给我让路。
问问题
1101 次
2 回答
9
它在 java 中为我工作。
MultigetSliceCounterQuery<String, String> query=HFactory.createMultigetSliceCounterQuery(keyspace, se, se);
query.setColumnFamily("MyCounters").setKeys(list).setRange(null, null, false, 3);
CounterRows<String,String> resultRows1 = query.execute().get();
for (CounterRow<String, String> row : resultRows1) {
System.out.println("Row Key "+ row.getKey());
for (HCounterColumn<String> col : row.getColumnSlice().getColumns())
System.out.println("column Name "+col.getName()+"column value "+col.getValue());
}
}
于 2014-04-05T14:11:46.133 回答
0
scala根据您的标签,您如何在 Scala 中进行操作
val query = HFactory.createMultigetSliceCounterQuery(keyspaceName, se, se)
query.setColumnFamily("counterFamily").setKeys(list).setRange(null, null, false,3)
val resultRows = query.execute().get
resultRows.map{row=>
var countStatus = new scala.collection.immutable.HashMap[S, S]()
row.getColumnSlice.getColumns.map{col=>
countStatus += (col.getName -> col.getValue)
}
println(row.getKey -> countStatus)
}
于 2014-11-01T10:50:10.217 回答