It's a bit more subtle than that.  Certain strings, [\xff]*, have no
end_row.  If you want all rows starting with '\xff\xff' say, you'd have to
set that as a lower bound and have no upper bound.  Here's some Python:

def prefixSuccessor(s):
    if not s:
        return None
    elif s[-1] != '\xff':
        return s[:-1] + chr(1+ord(s[-1]))
    else:
        return prefixSuccessor(s[:-1])

def test():
    assert prefixSuccessor('') == None
    assert prefixSuccessor('abc') == 'abd'
    assert prefixSuccessor('123\xff\xff') == '124'
    assert prefixSuccessor('\xff\xff\xff') == None

In the cases where the successor function returns None, you should have no
upper bound in your query.


On Thu, Jan 21, 2010 at 4:12 AM, Stanislav Yudin <[email protected]> wrote:

> Thanks Luke and Sanjit.
> That "magic" in Parser.h in case of python looks like:
> end_row_id = id[:len(start_row)-1] + chr(ord(start_row[len(start_row)-1:])
> + 1)
>
> So since we're going to use it, please try not to break start_row/end_row
> in RowInterval while refactoring.
>
>
> On Thu, Jan 21, 2010 at 5:03 AM, Sanjit Jhala <[email protected]> wrote:
>
>> Basically "bas" is the first string that sorts after everything that
>> starts with "bar". A simple way to generate it is add 1 to last non- 0xff
>> byte of the of the start row string.
>>
>> -Sanjit
>>
>>
>>
>> On Wed, Jan 20, 2010 at 10:20 AM, Stanislav Yudin <[email protected]>wrote:
>>
>>> Thanks Sanjit, but this is not a solution. I don't know what should be
>>> "bas" in my case, since all I have is a predicate for row key, so I have to
>>> supply something like "barXXXXXXXX..." as end row, which should be the last
>>> posible key with such predicate. What I am looking for is the same logic as
>>> in src/cc/HyperTable/Lib/HqlParser.h:783 onwards (which looks like black
>>> magic for me). Can you explain what is going on in HqlParser.h? I am using
>>> thrift bindings for python.
>>>
>>> On Wed, Jan 20, 2010 at 10:24 PM, Sanjit Jhala <[email protected]>wrote:
>>>
>>>> Hi Stanislav,
>>>>
>>>> Suppose you want to set up a scanner that returns all rows starting with
>>>> "bar". Setup a scanner with the row interval start_row = 'bar', end_row =
>>>> 'bas', start_inclusive = true, end_inclusive = false.
>>>>
>>>> Btw are you using the Thrift interface or the C++ client?
>>>>
>>>> -Sanjit
>>>>
>>>> On Wed, Jan 20, 2010 at 4:40 AM, Stanislav Yudin <[email protected]>wrote:
>>>>
>>>>> Hello everyone,
>>>>> I wonder what is the best way to setup ScanSpec which would do the same
>>>>> as =^ (or RELOP_SW) operator in HQL?
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Hypertable Development" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected]<hypertable-dev%[email protected]>
>>>>> .
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/hypertable-dev?hl=en.
>>>>>
>>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Hypertable Development" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected]<hypertable-dev%[email protected]>
>>>> .
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/hypertable-dev?hl=en.
>>>>
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Hypertable Development" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<hypertable-dev%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/hypertable-dev?hl=en.
>>>
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Hypertable Development" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<hypertable-dev%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/hypertable-dev?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hypertable Development" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<hypertable-dev%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/hypertable-dev?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups "Hypertable Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/hypertable-dev?hl=en.

Reply via email to