我想在hbase中对多个列使用范围筛选器。我知道我们可以使用singlecolumnvaluefilter实现和/或条件,但是我想对两个不同的列运行相同的筛选条件。example:myhbase table
rowkey,cf:bidprice,cf:askprice,cf:product
我想用 (cf:bidprice>10 and cf:bidprice<20) or (cf:askprice>10 and cf:askprice<20) .
(cf:bidprice>10 and cf:bidprice<20) or (cf:askprice>10 and cf:askprice<20)
vq8itlhq1#
我想我知道了。下面的代码片段是一个示例实现。
byte[] startRow=Bytes.toBytes("startrow"); byte[] endRow=Bytes.toBytes("stoprow"); SingleColumnValueFilter bidPriceGreaterFilter=new SingleColumnValueFilter("q".getBytes(), "bidprice".getBytes(), CompareFilter.CompareOp.GREATER_OR_EQUAL, "12345".getBytes()); SingleColumnValueFilter bidPricelesserFilter=new SingleColumnValueFilter("q".getBytes(), "bidprice".getBytes(), CompareFilter.CompareOp.LESS_OR_EQUAL, "12346".getBytes()); SingleColumnValueFilter askPriceGreaterFilter=new SingleColumnValueFilter("q".getBytes(), "askprice".getBytes(), CompareFilter.CompareOp.GREATER_OR_EQUAL, "12345".getBytes()); SingleColumnValueFilter askPricelesserFilter=new SingleColumnValueFilter("q".getBytes(), "askprice".getBytes(), CompareFilter.CompareOp.LESS_OR_EQUAL, "12346".getBytes()); FilterList andFilter1= new FilterList(FilterList.Operator.MUST_PASS_ALL); andFilter1.addFilter(bidPriceGreaterFilter); andFilter1.addFilter(bidPricelesserFilter); FilterList andFilter2= new FilterList(FilterList.Operator.MUST_PASS_ALL); andFilter2.addFilter(askPriceGreaterFilter); andFilter2.addFilter(askPricelesserFilter); FilterList finalFilterList=new FilterList(FilterList.Operator.MUST_PASS_ONE); finalFilterList.addFilter(andFilter1); finalFilterList.addFilter(andFilter2); Scan scan = new Scan(startRow,endRow); scan.setFilter(finalFilterList);
1条答案
按热度按时间vq8itlhq1#
我想我知道了。下面的代码片段是一个示例实现。