hbase中涉及到的过滤器

2020-03-02  本文已影响0人  风一样的存在

此处有坑,当匹配不到的时候就默认全部输出
解决办法:
filter.setFilterIfMissing(false);

List<Filter> filters = new ArrayList<Filter>();                        
filters.add(  new SingleColumnValueFilter(Bytes.toBytes("pinfo"),  //列族
                          Bytes.toBytes("t"),  //列名                                 
                          CompareOp.GREATER,Bytes.toBytes("1359901")) //值          
filters.add(  new SingleColumnValueFilter(Bytes.toBytes("pinfo"),        
                          Bytes.toBytes("t"),                                         
                          CompareOp.LESS,Bytes.toBytes("1389901"))                  
FilterList filterList1 = new FilterList(Operator.MUST_PASS_ALL,filters); 
sn.setFilter(filterList1);
for (int a=0;a<size;a++)                                                           
{                                                                         
   //Filter filter2 = new RowFilter(CompareOp.EQUAL,                         
   // new RegexStringComparator(".*"+maclist.get(a)+"$"));                  
   Filter filter2 = new RowFilter(CompareOp.EQUAL,                         
            new SubstringComparator(maclist.get(a)));                               
   filters.add(filter2);                                                     
}                                                                         
FilterList filterList1 = new FilterList(Operator.MUST_PASS_ONE,filters);  
sn.setFilter(filterList1);                                                
Scan scan = new Scan();                                                                      
System.out.println("只列出值包含data1的列");
Filter filter1 = new ValueFilter(CompareFilter.CompareOp.EQUAL,                   
        new SubstringComparator("data1"));
scan.setFilter(filter1);

参考
HBase学习之路 (六)过滤器

上一篇下一篇

猜你喜欢

热点阅读