• 过滤器查询


     hbase过滤器的分类

    1、比较过滤器

    行键过滤器 RowFilter
    Filter filter1 = new RowFilter(CompareOp.LESS_OR_EQUAL, new BinaryComparator(Bytes.toBytes("row-22")));
    scan.setFilter(filter1);
    
    列族过滤器 FamilyFilter
    Filter filter1 = new FamilyFilter(CompareFilter.CompareOp.LESS, new BinaryComparator(Bytes.toBytes("colfam3")));
    scan.setFilter(filter1);
    
    列过滤器 QualifierFilter
    Filter filter = new QualifierFilter(CompareFilter.CompareOp.LESS_OR_EQUAL, new  BinaryComparator(Bytes.toBytes("col-2")));
    scan.setFilter(filter1);
    
    值过滤器 ValueFilter
    Filter filter = new ValueFilter(CompareFilter.CompareOp.EQUAL, new SubstringComparator(".4") );
    scan.setFilter(filter1);

    2、专用过滤器

    单列值过滤器 SingleColumnValueFilter ----会返回满足条件的整行
    SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes("colfam1"),Bytes.toBytes("col-5"),CompareFilter.CompareOp.NOT_EQUAL,new SubstringComparator("val-5"));
    filter.setFilterIfMissing(true);  //如果不设置为 true,则那些不包含指定 column 的行也会返回
    scan.setFilter(filter1);
    
    前缀过滤器 PrefixFilter----针对行键
    Filter filter = new PrefixFilter(Bytes.toBytes("row1"));
    scan.setFilter(filter1);
    
    列前缀过滤器 ColumnPrefixFilter
    Filter filter = new ColumnPrefixFilter(Bytes.toBytes("qual2"));
    scan.setFilter(filter1);

    RowFilter

     

     api

    提取rowkey以01结尾数据
    Filter filter = new RowFilter(CompareFilter.CompareOp.EQUAL,new RegexStringComparator(".*01$"));
    
    提取rowkey以包含201407的数据
    Filter filter = new RowFilter(CompareFilter.CompareOp.EQUAL,new SubstringComparator("201407"));
    
    
    提取rowkey以123开头的数据
    Filter filter = new RowFilter(CompareFilter.CompareOp.EQUAL,new BinaryPrefixComparator("123".getBytes()));
    故乡明
  • 相关阅读:
    负数之美
    css重设
    编码问题
    wed的各种前端打印方法(3)CSS
    表单
    学习前端心得
    去除input,a,按键链接时出现的虚线方法
    加载事件js代码
    深入C#数据类型
    查找
  • 原文地址:https://www.cnblogs.com/luweiweicode/p/14808921.html
Copyright © 2020-2023  润新知