Cause: When using Happybase to access HBase
def scan (self, row_start=none, Row_stop=none, Row_prefix=none, Columns=none, Filter=none, Timestamp=none , Include_timestamp=false, batch_size=1000, Scan_batching=none, Limit=none, Sorted_columns=false):
There is a row_prefix parameter in the scan function, and this parameter does not appear in the Java Client counterpart function, what does it do?
View the source code, we can see
If Row_prefix is not none: if Row_start are not none or Row_stop are not none: raise TypeError ( "' Row_prefix ' CA Nnot be combined with ' Row_start ' "" or ' row_stop ' ") Row_start = row_prefix row_stop = str_increment (row_ Prefix
Specific code for Str_increment
def str_increment (s): "" " increment and truncate a byte string (for sorting purposes) This functions returns the SH Ortest string, sorts after the given string, when compared using regular string comparison semantics. This function increments the last byte, which is smaller than "0xFF", and drops everything after it. If the string only contains ' 0xFF ' bytes, ' None ' is returned. "" For i in Xrange (Len (s)-1,-1,-1): if s[i]! = ' \xff ': return s[:i] + chr (ORD (s[i]) + 1) return None
After reading the code, we should understand that Row_prefix was converted into Row_start and row_stop.
When you have the following scenario
Micro-Blog Watch
User id_ Weibo ID
Assuming we want to get all of this user's Weibo, there is no need to set the scan range ' user id_0 ' ~ ' user id_a ' on scan
And you can use Row_prefix = ' user ID' directly
PS: I will provide str_increment Java implementation later.
About Row_prefix parameters in Happybase