hbase 多个过滤器组合(列表)

使用FilterList要保证过滤器的顺序需要使用List<Filter>

 private static void mutilFilterData() throws IOException{
        Table table = helper.getConnection().getTable(TableName.valueOf("testtable"));

        List<Filter> filters = new ArrayList<Filter>();

        Filter filter1 = new RowFilter(CompareOperator.GREATER_OR_EQUAL,
                new BinaryComparator(Bytes.toBytes("rowKey60")));
        filters.add(filter1);

        Filter filter2 = new RowFilter(CompareOperator.LESS_OR_EQUAL,
                new BinaryComparator(Bytes.toBytes("rowKey69")));
        filters.add(filter2);

        Filter filter3 = new QualifierFilter(CompareOperator.EQUAL,
                new RegexStringComparator("username"));
        filters.add(filter3);

        FilterList filterList1 = new FilterList(FilterList.Operator.MUST_PASS_ALL,filters);

        Scan scan = new Scan();
        scan.setFilter(filterList1);
        ResultScanner scanner1 = table.getScanner(scan);
        System.out.println("Results of scan #1 - MUST_PASS_ALL:");
        int n = 0;
        for (Result result : scanner1) {
            for (Cell cell : result.rawCells()) {
                System.out.println("Cell: " + cell + ", Value: " +
                        Bytes.toString(cell.getValueArray(), cell.getValueOffset(),
                                cell.getValueLength()));
                n++;
            }
        }
        scanner1.close();
        table.close();

    }

输出结果:

Cell: rowKey60/info:username/1555078771906/Put/vlen=6/seqid=0, Value: user60
Cell: rowKey61/info:username/1555078771906/Put/vlen=6/seqid=0, Value: user61
Cell: rowKey62/info:username/1555078771906/Put/vlen=6/seqid=0, Value: user62
Cell: rowKey63/info:username/1555078771906/Put/vlen=6/seqid=0, Value: user63
Cell: rowKey64/info:username/1555078771906/Put/vlen=6/seqid=0, Value: user64
Cell: rowKey65/info:username/1555078771906/Put/vlen=6/seqid=0, Value: user65
Cell: rowKey66/info:username/1555078771906/Put/vlen=6/seqid=0, Value: user66
Cell: rowKey67/info:username/1555078771906/Put/vlen=6/seqid=0, Value: user67
Cell: rowKey68/info:username/1555078771906/Put/vlen=6/seqid=0, Value: user68
Cell: rowKey69/info:username/1555078771906/Put/vlen=6/seqid=0, Value: user69

 

转载于:https://www.cnblogs.com/asker009/p/10703134.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值