Scan HBase strings ignoring part of the start and end strings in Java

I have HBase strings as follows

ABC_A1_20160101 ABC_A2_20160102 ABC_A3_20160103 XYZ_A9_20160201 

from my java code. I know the first part of ABC and the last part of 20160101 . I can not get the middle part of A1, A2, A3....

In this case, how can I query in Java?

From ABC_A1_20160101 To ABC_A3_20160103

+1
java hbase
source share
1 answer

A fuzzy row approach is effective for this kind of requirements and when the data is huge: As explained in the article, FuzzyRowFilter takes as a parameter a string of string and information about the mask. In the above example, if we want to find the last registered users, and the format of the string key is userId_actionId_timestamp (where userId has a fixed length, for example 4 characters), the fuzzy string key we are looking for is "???? login". This leads to the following parameters for 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}))); 
+3
source share

All Articles