how to get value from counter Column in cassandra with multiple row keys?
Asked Answered
M

2

8

I have one column family that has multiple counter columns. Now I want to get their value behalf of different row keys, Means like RangeSlicesQuery or MultigetSliceQuery, I want to apply on counter column please give me way in counter column.

Migdaliamigeon answered 2/4, 2014 at 9:4 Comment(0)
I
9

its working for me in 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());
    }
}
Interlunation answered 5/4, 2014 at 14:11 Comment(0)
N
0

how you can do in Scala, according to your scala tag

    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)
    }
Nidify answered 1/11, 2014 at 10:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.