public void twoDimensionalCompositeRangeTest() {
boolean fail = false;
try {
final String rowkey = "mykey2";
AstyanaxContext<Keyspace> context = newContext("localhost:9160", KEYSPACE);
Keyspace ks = context.getEntity();
ColumnFamily<String, Composite> cf = new ColumnFamily<String, Composite>("composite2",
StringSerializer.get(), CompositeSerializer.get());
MutationBatch mutation = ks.prepareMutationBatch();
List<String> combinations = combinationsWithRepitition("abcdef", 3);
for(String str : combinations){
LOG.debug("Will insert '{}'", str);
mutation.withRow(cf, rowkey).putColumn(makeStringComposite(str.substring(0,1), str.substring(1,2), str.substring(2,3)), str);
}
mutation.execute();
// build up a composite range query
Composite start = makeStringEqualityComposite(new String[] { "a", "a", "a"}, new ComponentEquality[] {
ComponentEquality.EQUAL,ComponentEquality.EQUAL, ComponentEquality.EQUAL });
Composite end = makeStringEqualityComposite(new String[] { "a", "a", "b"}, new ComponentEquality[] {
ComponentEquality.EQUAL,ComponentEquality.EQUAL, ComponentEquality.EQUAL });
ColumnFamilyQuery<String, Composite> query = ks.prepareQuery(cf);
ColumnList<Composite> results = query.getKey(rowkey)
.withColumnRange(start.serialize(), end.serialize(), false, 100).execute().getResult();
LOG.debug("Query matched {} results.", results.size());
for (Composite columnKey : results.getColumnNames()) {
// LOG.debug("Component(0): {}", columnKey.getComponent(0).getValue(StringSerializer.get()));