组合类型最后组件上的通配符 [英] Composite Type Wildcard on last component

查看:158
本文介绍了组合类型最后组件上的通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码段。复合列有两个组成部分。如果我只知道第一个组件,是否可以检索列?在某种意义上,对复合材料的一些组件(尤其是最后一个组件)应用一些稀释卡片选择。

I have the following code segment. The composite column has two compoents. Is it possible to retrieve columns if I know only the first component? In some sense, apply some dilcards election on the some of the components of the composite (especially the last component).

谢谢。

 Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer);
    String key="TX:512";
    String CF="StateNpaIndexStatic";
    HColumnImpl<Composite, String> column = new HColumnImpl<Composite, String>(cs, StringSerializer.get());
    column.setClock(keyspace.createClock());
    Composite dc = new Composite();
    dc.add(0, "review");
    dc.add(1, "T23333");
    column.setName(dc);       
    column.setValue("aa");
    mutator.addInsertion(key, CF, column);
    mutator.execute();
     Composite start = new Composite();
    start.add(0, start0);
    start.add(1,"*");
    Composite end = new Composite();
    end.add(0, end0);
    end.add(1, "*");

    SliceQuery<String,Composite, String> sliceQuery =HFactory.createSliceQuery(keyspace,stringSerializer, CompositeSerializer.get(), StringSerializer.get());
    sliceQuery.setColumnFamily(CF);
    sliceQuery.setKey(key);
    sliceQuery.setRange(start, start, false, 1);
    QueryResult<ColumnSlice<Composite, String>> result = sliceQuery.execute();
    System.out.println("Result :"+result.get().getColumns().size()+"=========="+result);


推荐答案

您不必指定所有组件复合材料。你可以错过最后(但不是中间或开始),并对这些进行范围查询,而不是像传递空范围到正常列上的get_slice查询。

You don't have to specify all the components in the composite. You can miss ones off the end (but not the middle or beginning) and do a range query on these, rather like passing in empty ranges into a get_slice query on normal columns.

如果在您的示例中,您使用

If, in your example, you did a query with

Composite start = new Composite();
start.addComponent(0, start0, ComponentEquality.EQUAL);
Composite end = new Composite();
end.add(0, end0, ComponentEquality.GREATER_THAN_EQUAL);

你会得到以start0开头到end0的所有内容。 ComponentEquality标志设置是否包括结束范围。上面的包括开始和结束。您将使用ComponentEquality.GREATER_THAN_EQUAL排除开头;以排除最终用途ComponentEquality.EQUAL。

you would get everything that starts with start0 up to end0. The ComponentEquality flags set whether to include or exclude the end ranges. The ones above include both start and end. You would exclude the beginning with ComponentEquality.GREATER_THAN_EQUAL; to exclude the end use ComponentEquality.EQUAL.

这篇关于组合类型最后组件上的通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆