You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Zhou Wei <zh...@mails.tsinghua.edu.cn> on 2008/04/29 04:53:28 UTC
obtain the maximum value of the row id of a table
Hi
I want to find out the maximum value of the row id of a table.
Is there a simple and efficient way to do this without scan through the
whole table starting from the first row?
Thanks.
Zhou
Re: obtain the maximum value of the row id of a table
Posted by Zhou Wei <zh...@mails.tsinghua.edu.cn>.
Jim Kellerman wrote:
> What are you using for the row key?
>
The row key is set by the primary key of the "original table" defined in
relational model.
Sometimes, multiple relational tables are required to be joined into one
"bigtable"
In this case, I use the primary key of relational table "Order" as the
row key.
> ---
> Jim Kellerman, Senior Engineer; Powerset
>
>
>
>> -----Original Message-----
>> From: Zhou Wei [mailto:zhouwei04@mails.tsinghua.edu.cn]
>> Sent: Tuesday, April 29, 2008 9:02 AM
>> To: hbase-user@hadoop.apache.org
>> Subject: Re: obtain the maximum value of the row id of a table
>>
>> Bryan Duxbury wrote:
>>
>>> No, we can't scan in reverse. I don't think it's possible to do so
>>> with the components we have today - there's no previous method on
>>> mapfile, only next. Out of curiosity, hat's the use case
>>>
RE: obtain the maximum value of the row id of a table
Posted by Jim Kellerman <ji...@powerset.com>.
What are you using for the row key?
---
Jim Kellerman, Senior Engineer; Powerset
> -----Original Message-----
> From: Zhou Wei [mailto:zhouwei04@mails.tsinghua.edu.cn]
> Sent: Tuesday, April 29, 2008 9:02 AM
> To: hbase-user@hadoop.apache.org
> Subject: Re: obtain the maximum value of the row id of a table
>
> Bryan Duxbury wrote:
> > No, we can't scan in reverse. I don't think it's possible to do so
> > with the components we have today - there's no previous method on
> > mapfile, only next. Out of curiosity, hat's the use case
> for getting
> > the last N records in the table?
> >
> > -Bryan
> >
> The use cases come from a standard transactional web
> application benchmark TPC-W, which models an online bookshop.
>
> Use cases:
> 1) obtain the latest order of a specified user As new order
> is inserted at the end of table, it is better to start scan
> in reverse direction.
>
> 2) obtain the top 50 books which sells best recently.
> The calculation is based on the information of 3333 most
> recent orders.
> Again, better to start scan from the end of table.
>
> - Zhou
> > On Apr 29, 2008, at 8:08 AM, Zhou Wei wrote:
> >
> >>
> >>> Hm, tricky. You don't have the scan the whole table -
> just the last
> >>> region. You can find out what the start key of the last
> region is by
> >>> using HTable#getStartKeys. If this isn't an acceptable
> solution, we
> >>> might be able to think up a way to get the last real row
> of a table
> >>> more efficiently.
> >> Actually, I need to obtain the 3333 rows starting from the
> last row
> >> rather than the first row.
> >> So I wonder is it possible to obtain a scanner that scan in the
> >> reverse direction.
> >> I.e. Starting from the last row to the first row.
> >>
> >> Zhou
> >>>
> >>> -Bryan
> >>>
> >>> On Apr 28, 2008, at 7:53 PM, Zhou Wei wrote:
> >>>
> >>>> Hi
> >>>>
> >>>> I want to find out the maximum value of the row id of a table.
> >>>> Is there a simple and efficient way to do this without
> scan through
> >>>> the whole table starting from the first row?
> >>>>
> >>>> Thanks.
> >>>>
> >>>> Zhou
> >>>
> >>>
> >>>
> >>
> >
> >
> >
>
>
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.524 / Virus Database: 269.23.6/1403 - Release
> Date: 4/29/2008 7:26 AM
>
>
No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.524 / Virus Database: 269.23.6/1403 - Release Date: 4/29/2008 7:26 AM
Re: obtain the maximum value of the row id of a table
Posted by Zhou Wei <zh...@mails.tsinghua.edu.cn>.
Bryan Duxbury wrote:
> No, we can't scan in reverse. I don't think it's possible to do so
> with the components we have today - there's no previous method on
> mapfile, only next. Out of curiosity, hat's the use case for getting
> the last N records in the table?
>
> -Bryan
>
The use cases come from a standard transactional web application
benchmark TPC-W, which models an online bookshop.
Use cases:
1) obtain the latest order of a specified user
As new order is inserted at the end of table,
it is better to start scan in reverse direction.
2) obtain the top 50 books which sells best recently.
The calculation is based on the information of 3333 most recent orders.
Again, better to start scan from the end of table.
- Zhou
> On Apr 29, 2008, at 8:08 AM, Zhou Wei wrote:
>
>>
>>> Hm, tricky. You don't have the scan the whole table - just the last
>>> region. You can find out what the start key of the last region is by
>>> using HTable#getStartKeys. If this isn't an acceptable solution, we
>>> might be able to think up a way to get the last real row of a table
>>> more efficiently.
>> Actually, I need to obtain the 3333 rows starting from the last row
>> rather than the first row.
>> So I wonder is it possible to obtain a scanner that scan in the
>> reverse direction.
>> I.e. Starting from the last row to the first row.
>>
>> Zhou
>>>
>>> -Bryan
>>>
>>> On Apr 28, 2008, at 7:53 PM, Zhou Wei wrote:
>>>
>>>> Hi
>>>>
>>>> I want to find out the maximum value of the row id of a table.
>>>> Is there a simple and efficient way to do this without scan through
>>>> the
>>>> whole table starting from the first row?
>>>>
>>>> Thanks.
>>>>
>>>> Zhou
>>>
>>>
>>>
>>
>
>
>
Re: obtain the maximum value of the row id of a table
Posted by Bryan Duxbury <br...@rapleaf.com>.
No, we can't scan in reverse. I don't think it's possible to do so
with the components we have today - there's no previous method on
mapfile, only next. Out of curiosity, hat's the use case for getting
the last N records in the table?
-Bryan
On Apr 29, 2008, at 8:08 AM, Zhou Wei wrote:
>
>> Hm, tricky. You don't have the scan the whole table - just the
>> last region. You can find out what the start key of the last
>> region is by using HTable#getStartKeys. If this isn't an
>> acceptable solution, we might be able to think up a way to get the
>> last real row of a table more efficiently.
> Actually, I need to obtain the 3333 rows starting from the last row
> rather than the first row.
> So I wonder is it possible to obtain a scanner that scan in the
> reverse direction.
> I.e. Starting from the last row to the first row.
>
> Zhou
>>
>> -Bryan
>>
>> On Apr 28, 2008, at 7:53 PM, Zhou Wei wrote:
>>
>>> Hi
>>>
>>> I want to find out the maximum value of the row id of a table.
>>> Is there a simple and efficient way to do this without scan
>>> through the
>>> whole table starting from the first row?
>>>
>>> Thanks.
>>>
>>> Zhou
>>
>>
>>
>
Re: obtain the maximum value of the row id of a table
Posted by Zhou Wei <zh...@mails.tsinghua.edu.cn>.
> Hm, tricky. You don't have the scan the whole table - just the last
> region. You can find out what the start key of the last region is by
> using HTable#getStartKeys. If this isn't an acceptable solution, we
> might be able to think up a way to get the last real row of a table
> more efficiently.
Actually, I need to obtain the 3333 rows starting from the last row
rather than the first row.
So I wonder is it possible to obtain a scanner that scan in the reverse
direction.
I.e. Starting from the last row to the first row.
Zhou
>
> -Bryan
>
> On Apr 28, 2008, at 7:53 PM, Zhou Wei wrote:
>
>> Hi
>>
>> I want to find out the maximum value of the row id of a table.
>> Is there a simple and efficient way to do this without scan through the
>> whole table starting from the first row?
>>
>> Thanks.
>>
>> Zhou
>
>
>
Re: obtain the maximum value of the row id of a table
Posted by Bryan Duxbury <br...@rapleaf.com>.
Hm, tricky. You don't have the scan the whole table - just the last
region. You can find out what the start key of the last region is by
using HTable#getStartKeys. If this isn't an acceptable solution, we
might be able to think up a way to get the last real row of a table
more efficiently.
-Bryan
On Apr 28, 2008, at 7:53 PM, Zhou Wei wrote:
> Hi
>
> I want to find out the maximum value of the row id of a table.
> Is there a simple and efficient way to do this without scan through
> the
> whole table starting from the first row?
>
> Thanks.
>
> Zhou