0

I have a super column family and everything works well when I query like this:

private static Cluster cluster = HFactory.getOrCreateCluster("cluster1", "localhost:9160");
private static Keyspace keyspace = HFactory.createKeyspace("keyspace1",cluster);
private static Serializer se = StringSerializer.get();
SuperColumnQuery<String, String, String, String> scq = HFactory.createSuperColumnQuery(keyspace, se, se, se, se);
scq.setColumnFamily("step_wise_stats")
.setKey("1001")
.setSuperName("124");
QueryResult<HSuperColumn<String, String, String>> qres = scq.execute();
System.out.println(qres.get());

But there are more super names under key 1001 such as 125, 126 etc.. And those are dynamic too (I don't know those names in advance). How do I query them all?

1 Answers1

0

Many of experts and documentation suggest that to go with composite column is far better than that of Super Column because lack of secondary indices in that...so if possible use Composite Column.Otherwise in this case you should use timeUUID in place of your dynamic values and try with MultigetSubSliceQuery , make changes with below code,this might increase your programming efforts to generate required result

ArrayList<String> listco = new ArrayList<String>();
        listco.add("1001");


listco.add("1002");

MultigetSubSliceQuery<String,String, String, String> rangeSlicesQuery =
                HFactory.
                createMultigetSubSliceQuery(keyspace,stringSerializer,    stringSerializer, stringSerializer, stringSerializer);

rangeSlicesQuery.setColumnFamily("step_wise_stats");
rangeSlicesQuery.setSuperColumn("your super column");

rangeSlicesQuery.setKeys(listco);
rangeSlicesQuery.setRange("", "", false, 1000);
QueryResult<Rows<String, String, String>> result = rangeSlicesQuery.execute();
Hardik Bhalani
  • 863
  • 2
  • 8
  • 24
  • But the problem still persist.. I dont know the super column name.. So cant use - rangeSlicesQuery.setSuperColumn("your super column"); - I need them all.. – Gireesh Puthumana Jun 17 '13 at 07:05
  • "this might increase your programming ..." means you have to use timeUUID or timekey(e.g. yyyymmddHH = 2013061713 ) as super column name than you have to fetch that timeUUID/timekey and manually traverse time in order,you can achieve this programatically – Hardik Bhalani Jun 17 '13 at 07:33