hbase的模糊查询(利用过滤器)

本文介绍了HBase的行键过滤器RowFilter,包括各种比较符和Comparator的使用,如BinaryComparator、BinaryPrefixComparator、NullComparator、BitComparator、RegexStringComparator和SubstringComparator。通过设置开始和结束行键范围,结合FilterList和PageFilter实现特定条件的查询,并给出了匹配以特定字符串开始或结束的rowkey的例子。
摘要由CSDN通过智能技术生成
  1. 行键过滤器RowFilter
    比较符如下:

Operator Description
LESS 小于
LESS_OR_EQUAL 小于等于
EQUAL 等于
NOT_EQUAL 不等于
GREATER_OR_EQUAL 大于等于
GREATER 大于
NO_OP 排除所有

Comparator Description
BinaryComparator 使用Bytes.compareTo()比较
BinaryPrefixComparator 和BinaryComparator差不多,从前面开始比较
NullComparator Does not compare against an actual value but whether a given one is null, or not null.
BitComparator Performs a bitwise comparison, providing a BitwiseOp class with AND, OR, and XOR operators.
RegexStringComparator 正则表达式
SubstringComparator 把数据当成字符串,用contains()来判断
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会导致全表扫描,所以一

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值