简体   繁体   English

通过忽略Java中开始和结束行的一部分来扫描HBase行

[英]Scan HBase rows by ignoring a part of the start and end row in Java

I have HBase rows as follows 我有如下的HBase行

ABC_A1_20160101
ABC_A2_20160102
ABC_A3_20160103
XYZ_A9_20160201

from my Java code I know first part ABC and last part 20160101 . 从我的Java代码中,我知道第一部分ABC和最后一部分20160101 There is no way I can get the middle part A1, A2, A3.... . 我无法获得中间部分A1, A2, A3....

In this case how can I query in Java ? 在这种情况下,如何使用Java查询?

From ABC_A1_20160101 To ABC_A3_20160103 ABC_A1_20160101ABC_A3_20160103

Fuzzy row approach is efficient for this kind of requirement and when data is is huge : As explained by this article FuzzyRowFilter takes as parameters row key and a mask info. 模糊行方法对于这种要求以及数据量很大时非常有效:如本文所述, FuzzyRowFilter将行键和掩码信息作为参数。 In example above, in case we want to find last logged in users and row key format is userId_actionId_timestamp (where userId has fixed length of say 4 chars), the fuzzy row key we are looking for is “???? 在上面的示例中,如果我们要查找上次登录的用户并且行键格式为userId_actionId_timestamp(其中userId的固定长度为4个字符),则我们要查找的模糊行键为“ ????”。 login ”. 登录 ”。 This translates into the following params for FuzzyRowKey: 这转化为FuzzyRowKey的以下参数:

FuzzyRowFilter rowFilter = new FuzzyRowFilter(
 Arrays.asList(
  new Pair<byte[], byte[]>(
    Bytes.toBytesBinary("\x00\x00\x00\x00_login_"),
    new byte[] {1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0})));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM