阅读:4797回复:0
hbase过滤器1. 行键过滤器RowFilter 比较符如下: Operator [/td][td=1,1,145]Description [/td][/tr][tr][td=1,1,253]
LESS[/td][td=1,1,145] 小于[/td][/tr][tr][td=1,1,253] LESS_OR_EQUAL[/td][td=1,1,145] 小于等于[/td][/tr][tr][td=1,1,253] EQUAL[/td][td=1,1,145] 等于[/td][/tr][tr][td=1,1,253] NOT_EQUAL[/td][td=1,1,145] 不等于[/td][/tr][tr][td=1,1,253] GREATER_OR_EQUAL[/td][td=1,1,145] 大于等于[/td][/tr][tr][td=1,1,253] GREATER[/td][td=1,1,145] 大于[/td][/tr][tr][td=1,1,253] NO_OP[/td][td=1,1,145] 排除所有[/td][/tr][/table] [table=0,white,,0,0][tr][td=1,1,235] Comparator [/td][td=1,1,274]Description [/td][/tr][tr][td=1,1,235]
BinaryComparator[/td][td=1,1,274] 使用Bytes.compareTo()比较[/td][/tr][tr][td=1,1,235] BinaryPrefixComparator[/td][td=1,1,274] 和BinaryComparator差不多,从前面开始比较[/td][/tr][tr][td=1,1,235] NullComparator[/td][td=1,1,274] Does not compare against an actual value but whether a given one is null, or not null.[/td][/tr][tr][td=1,1,235] BitComparator[/td][td=1,1,274] Performs a bitwise comparison, providing a BitwiseOp class with AND, OR, and XOR operators.[/td][/tr][tr][td=1,1,235] RegexStringComparator[/td][td=1,1,274] 正则表达式[/td][/tr][tr][td=1,1,235] SubstringComparator[/td][td=1,1,274] 把数据当成字符串,用contains()来判断[/td][/tr][/table] Scan scan = new Scan(); // FilterList.Operator.MUST_PASS_ALL---满足所有过滤器 FilterList list = new
FilterList(FilterList.Operator.MUST_PASS_ALL); String rowKeyStart =
range.remove("rowKeyStart").toString(); String rowKeyEnd =
range.remove("rowKeyEnd").toString(); //因为scan会导致全表扫描,所以一般会设置开始及结束行键范围查找 if (range.get("latesttime") !=
null&& !"".equals(range.get("latesttime"))) { scan.setReversed(true);//反向查找时,scan的开始行键和结束行键必须也反向 scan.setStartRow(rowKeyEnd.getBytes()); scan.setStopRow(rowKeyStart.getBytes()); } else { scan.setStartRow(rowKeyStart.getBytes()); scan.setStopRow(rowKeyEnd.getBytes()); } //匹配rowkey以dDataId 结束的数据 RowFilter rowFilter = new
RowFilter(CompareFilter.CompareOp.EQUAL, new
RegexStringComparator(".*" + dDataId + "$")); list.addFilter(rowFilter); Filter filter = new PageFilter(limit);//条数限制 list.addFilter(filter); scan.setFilter(list); //匹配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())); |
|