如何从cassandra cli中的列族中获取所有行键?

时间:2014-03-20 09:00:06

标签: scala playframework playframework-2.0 cassandra cassandra-cli

使用hector

从cassandra cli中的列族中获取所有rowkey
val query=HFactory.createRangesliceQuery(keyspace,le,se,se)
query.setColumnFamily("myInfo").setKeys(Integer.MIN_VALUE,Integer.MAX_Value).execute()

OR

val query=HFactory.createRangesliceQuery(keyspace,le,se,se)
query.setColumnFamily("myInfo").setKeys(Integer.MIN_VALUE,Integer.MAX_Value).setRange("","",true,10).execute()

2 个答案:

答案 0 :(得分:3)

这将有助于你

val rangeSlice = HFactory.createRangeSlicesQuery(keyspace, se, se, se)
rangeSlice.setColumnFamily("myInfo")
rangeSlice.setKeys(null, null)
rangeSlice.setRange(null, null, true, Int.MaxValue)
val bIterator = rangeSlice.execute().get.iterator()
while (bIterator.hasNext()) {
  val myRow = bIterator.next()
  val myKey = myRow.getKey()
  println(myKey+"<<<this is key")
  }

答案 1 :(得分:0)

    val rangeSlice = HFactory.createRangeSlicesQuery(keyspace, se, se, se)
rangeSlice.setColumnFamily("myTable")
rangeSlice.setReturnKeysOnly();
val bIterator = rangeSlice.execute().get.iterator()
while (bIterator.hasNext()) {
val myKey =bIterator.next().getKey()
 println(myKey+"<<<this is key")
}

它也会起作用