문제

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?

도움이 되었습니까?

해결책

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top