189 8069 5689

HBaseFilter使用方法(一)

一、FilterList

成都创新互联公司是一家专注于网站制作、网站设计与策划设计,集美网站建设哪家好?成都创新互联公司做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:集美等地区。集美做网站价格咨询:028-86922220

 // 通过将operator参数设置为Operator.MUST_PASS_ONE,达到list中各filter为"或"的关系   or
 // 默认operator参数的值为Operator.MUST_PASS_ALL,即list中各filter为"并"的关系       and
    FilterList f=new FilterList(FilterList.Operator.MUST_PASS_ONE);

二、几大Filter

1、Comparision Filters

      1.1 RowFilter     √

1.2 FamilyFilter √

      1.3 QualifierFilter     √

      1.4 ValueFilter √

      1.5 DependentColumnFilter ×

2、Dedicated Filters

      2.1 SingleColumnValueFilter ×

      2.2 SingleColumnValueExcludeFilter×

      2.3 PrefixFilter ×

      2.4 PageFilter ×

      2.5 KeyOnlyFilter ×

      2.6 FirstKeyOnlyFilter ×

      2.7 TimestampsFilter ×

      2.8 RandomRowFilter ×

3、Decorating Filters

      3.1 SkipFilter ×

      3.2 WhileMatchFilters ×


1.1   RowFilter 

格式:RowFilter(CompareFilter.CompareOp rowCompareOp, ByteArrayComparable rowComparator)

参数一  OperatorDescription

LESS小于

LESS_OR_EQUAL小于等于

EQUAL等于

NOT_EQUAL不等于

GREATER_OR_EQUAL大于等于

GREATER大于

NO_OP排除所有

参数二  ByteArrayComparable  可用

BinaryComparator, BinaryPrefixComparator, BitComparator, LongComparator, NullComparator, RegexStringComparator, SubstringComparator

例子:Filter filter=new RowFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes(RowKey))

相关的过滤方法使用:

提取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()));

提取rowkey小于等于row010的行

Filter filter1 = new RowFilter(CompareFilter.CompareOp.LESS_OR_EQUAL,new BinaryComparator("row010".getBytes()));

 1.2   FamilyFilter(同上)

1.3   QualifierFilter(同上)--------当列为数字,不管用了?why--------

1.4   ValueFilter(同上)

1.5   DependentColumnFilter   未完待续!


网页名称:HBaseFilter使用方法(一)
新闻来源:http://cdxtjz.cn/article/ishddd.html

其他资讯