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?

4

1 回答 1

0

许多专家和文档建议使用复合列比使用超级列要好得多,因为其中缺少二级索引......所以如果可能的话使用复合列。否则在这种情况下你应该使用 timeUUID 代替你的动态值并尝试使用MultigetSubSliceQuery以下代码进行更改,这可能会增加您的编程工作以生成所需的结果

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();
于 2013-06-17T06:30:20.597 回答