About Row_prefix parameters in Happybase

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.