本文介绍了HBase:扫描包含字符串的行键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个包含以下行键格式的HBase表格: < salt>:< id>#<< ;类别>#<类> 000001:1234#AAAAAAAAAA#BBBBBBB 000001:2345#CCCCCCCCCC#DDDDDDD 000002:1234#EEEEEEEEEE#FFFFFFF ... 我想在行键上输入 Scan 并获得密钥包含 id = 1234 的所有行。是否可以向 PrefixFilter regex 或 SubstringComparator 在添加盐之前, PrefixFilter 完美地适用于 id $ b 或者是否有其他可能性来搜索这个关键部分? import org.apache.hadoop.hbase.filter.CompareFilter; import org.apache.hadoop.hbase.filter.RegexStringComparator; import org.apache.hadoop.hbase.filter.RowFilter; RowFilter filter = new RowFilter( CompareFilter.CompareOp.EQUAL, new RegexStringComparator(your_regexp)); I have a HBase table containing the following row key format:<salt>:<id>#<category>#<class>000001:1234#AAAAAAAAAA#BBBBBBB000001:2345#CCCCCCCCCC#DDDDDDD000002:1234#EEEEEEEEEE#FFFFFFF...I'd like to make a Scan on the Row Keys and get all the rows where the key contains id=1234. Is it possible to add a regex or a SubstringComparator to the PrefixFilter (the PrefixFilter worked perfectly for the id filtering before I added the salt value in front of the key)?Or are there other possibilities to search for this key part? 解决方案 You need a RowFilter with RegexStringComparator:import org.apache.hadoop.hbase.filter.CompareFilter;import org.apache.hadoop.hbase.filter.RegexStringComparator;import org.apache.hadoop.hbase.filter.RowFilter;RowFilter filter = new RowFilter( CompareFilter.CompareOp.EQUAL, new RegexStringComparator("your_regexp")); 这篇关于HBase:扫描包含字符串的行键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!