You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by de Souza Medeiros Andre <an...@aalto.fi> on 2012/03/08 17:25:20 UTC

HTable.getEndKeys() returning empty results

Hi all,

Has someone had problems with HTable.getEndKeys() method? In my application it returns an array of byte[], but the first (and only) byte[] is empty, so essentially it's telling me that the (single) region has no end key.

The table has 3 rows and I'm running standalone HBase 0.90.4 CDH3u3 on my local machine. Moreover, the call getEndKeys() is executed immediately after I put rows in the table.

Do I need to wait until the .META. table gets updated with the regions' end row keys?
Does HTable.getEndKeys() work only in a fully distributed mode?
Is there any other way of getting the last row in a table? (this is my objective after all)

Thanks in advance,
-- Andre Medeiros

RE: HTable.getEndKeys() returning empty results

Posted by de Souza Medeiros Andre <an...@aalto.fi>.
Ok, now I'm not sure if I what I just said can be done.

According to Lars George's book, in HBase "there are no index files that allow such direct access of a particular row or column.". Does this mean that my scan "starting" at the given pointer will actually start scanning from the beginning of the block in HFile, ignoring everything until it scans the row I specified as the start? 
________________________________________
From: de Souza Medeiros Andre [andre.medeiros@aalto.fi]
Sent: Friday, March 09, 2012 12:02
To: user@hbase.apache.org
Subject: RE: HTable.getEndKeys() returning empty results

Hi Drz,

Yes, I've thought about that problem. But I've got an idea that sounds quite ok. Since scanning seems to be the only way of getting the last data row of table A, one can implement a "counter" table (single row, single column) to point to the row in A where the scanner should start. The counter value can be periodically updated to improve the performance of scanners.

Thanks for the support

-- Andre Medeiros
________________________________________
From: Michael Drzal [mdrzal@gmail.com]
Sent: Thursday, March 08, 2012 23:28
To: user@hbase.apache.org
Subject: Re: HTable.getEndKeys() returning empty results

On Thu, Mar 8, 2012 at 2:50 PM, de Souza Medeiros Andre <
andre.medeiros@aalto.fi> wrote:

> Thanks for the answer.
> This is quite confusing though, what is the point of having a method to
> retrieve the last key if we know that anyway it will be an empty byte array?
>
> Or does this happen only with one-region tables?
>
> Any way, is there some way of getting the last _data_ row of a table?
> Other than scanning the whole thing...
>

Think about it this way:

   - the last key for the region is key099
   - you insert key100
   - you insert key101
   - you insert key102

Do you really want the meta table updated for each an every insert that
touches the end?

  Drz


> Thanks,
> - Andre Medeiros
> ________________________________________
> From: saint.ack@gmail.com [saint.ack@gmail.com] on behalf of Stack [
> stack@duboce.net]
> Sent: Thursday, March 08, 2012 18:48
> To: user@hbase.apache.org
> Subject: Re: HTable.getEndKeys() returning empty results
>
> On Thu, Mar 8, 2012 at 8:25 AM, de Souza Medeiros Andre
> <an...@aalto.fi> wrote:
> > Hi all,
> >
> > Has someone had problems with HTable.getEndKeys() method? In my
> application it returns an array of byte[], but the first (and only) byte[]
> is empty, so essentially it's telling me that the (single) region has no
> end key.
> >
> > The table has 3 rows and I'm running standalone HBase 0.90.4 CDH3u3 on
> my local machine. Moreover, the call getEndKeys() is executed immediately
> after I put rows in the table.
> >
> > Do I need to wait until the .META. table gets updated with the regions'
> end row keys?
> > Does HTable.getEndKeys() work only in a fully distributed mode?
> > Is there any other way of getting the last row in a table? (this is my
> objective after all)
> >
>
> An empty byte array is the last key in a table of one region only.  An
> hbase table uses empty byte array as both the start and end row
> signifier as per the bigtable paper (I don't see this explicitly
> called out in the reference guide but I'm probably not looking in
> right place).
>
> St.Ack
>

RE: HTable.getEndKeys() returning empty results

Posted by de Souza Medeiros Andre <an...@aalto.fi>.
Hi Drz,

Yes, I've thought about that problem. But I've got an idea that sounds quite ok. Since scanning seems to be the only way of getting the last data row of table A, one can implement a "counter" table (single row, single column) to point to the row in A where the scanner should start. The counter value can be periodically updated to improve the performance of scanners.

Thanks for the support 

-- Andre Medeiros
________________________________________
From: Michael Drzal [mdrzal@gmail.com]
Sent: Thursday, March 08, 2012 23:28
To: user@hbase.apache.org
Subject: Re: HTable.getEndKeys() returning empty results

On Thu, Mar 8, 2012 at 2:50 PM, de Souza Medeiros Andre <
andre.medeiros@aalto.fi> wrote:

> Thanks for the answer.
> This is quite confusing though, what is the point of having a method to
> retrieve the last key if we know that anyway it will be an empty byte array?
>
> Or does this happen only with one-region tables?
>
> Any way, is there some way of getting the last _data_ row of a table?
> Other than scanning the whole thing...
>

Think about it this way:

   - the last key for the region is key099
   - you insert key100
   - you insert key101
   - you insert key102

Do you really want the meta table updated for each an every insert that
touches the end?

  Drz


> Thanks,
> - Andre Medeiros
> ________________________________________
> From: saint.ack@gmail.com [saint.ack@gmail.com] on behalf of Stack [
> stack@duboce.net]
> Sent: Thursday, March 08, 2012 18:48
> To: user@hbase.apache.org
> Subject: Re: HTable.getEndKeys() returning empty results
>
> On Thu, Mar 8, 2012 at 8:25 AM, de Souza Medeiros Andre
> <an...@aalto.fi> wrote:
> > Hi all,
> >
> > Has someone had problems with HTable.getEndKeys() method? In my
> application it returns an array of byte[], but the first (and only) byte[]
> is empty, so essentially it's telling me that the (single) region has no
> end key.
> >
> > The table has 3 rows and I'm running standalone HBase 0.90.4 CDH3u3 on
> my local machine. Moreover, the call getEndKeys() is executed immediately
> after I put rows in the table.
> >
> > Do I need to wait until the .META. table gets updated with the regions'
> end row keys?
> > Does HTable.getEndKeys() work only in a fully distributed mode?
> > Is there any other way of getting the last row in a table? (this is my
> objective after all)
> >
>
> An empty byte array is the last key in a table of one region only.  An
> hbase table uses empty byte array as both the start and end row
> signifier as per the bigtable paper (I don't see this explicitly
> called out in the reference guide but I'm probably not looking in
> right place).
>
> St.Ack
>

Re: HTable.getEndKeys() returning empty results

Posted by Michael Drzal <md...@gmail.com>.
On Thu, Mar 8, 2012 at 2:50 PM, de Souza Medeiros Andre <
andre.medeiros@aalto.fi> wrote:

> Thanks for the answer.
> This is quite confusing though, what is the point of having a method to
> retrieve the last key if we know that anyway it will be an empty byte array?
>
> Or does this happen only with one-region tables?
>
> Any way, is there some way of getting the last _data_ row of a table?
> Other than scanning the whole thing...
>

Think about it this way:

   - the last key for the region is key099
   - you insert key100
   - you insert key101
   - you insert key102

Do you really want the meta table updated for each an every insert that
touches the end?

  Drz


> Thanks,
> - Andre Medeiros
> ________________________________________
> From: saint.ack@gmail.com [saint.ack@gmail.com] on behalf of Stack [
> stack@duboce.net]
> Sent: Thursday, March 08, 2012 18:48
> To: user@hbase.apache.org
> Subject: Re: HTable.getEndKeys() returning empty results
>
> On Thu, Mar 8, 2012 at 8:25 AM, de Souza Medeiros Andre
> <an...@aalto.fi> wrote:
> > Hi all,
> >
> > Has someone had problems with HTable.getEndKeys() method? In my
> application it returns an array of byte[], but the first (and only) byte[]
> is empty, so essentially it's telling me that the (single) region has no
> end key.
> >
> > The table has 3 rows and I'm running standalone HBase 0.90.4 CDH3u3 on
> my local machine. Moreover, the call getEndKeys() is executed immediately
> after I put rows in the table.
> >
> > Do I need to wait until the .META. table gets updated with the regions'
> end row keys?
> > Does HTable.getEndKeys() work only in a fully distributed mode?
> > Is there any other way of getting the last row in a table? (this is my
> objective after all)
> >
>
> An empty byte array is the last key in a table of one region only.  An
> hbase table uses empty byte array as both the start and end row
> signifier as per the bigtable paper (I don't see this explicitly
> called out in the reference guide but I'm probably not looking in
> right place).
>
> St.Ack
>

Re: HTable.getEndKeys() returning empty results

Posted by Michael Drzal <md...@gmail.com>.
On Thu, Mar 8, 2012 at 2:52 PM, Stack <st...@duboce.net> wrote:

> On Thu, Mar 8, 2012 at 11:50 AM, de Souza Medeiros Andre
> <an...@aalto.fi> wrote:
> > Or does this happen only with one-region tables?
> >
> Yes
>

Even with multiregion tables, you will still get a null start key for the
first region and a null end key for the last unless I am missing something.



>
> > Any way, is there some way of getting the last _data_ row of a table?
> Other than scanning the whole thing...
> >
>
> No.
>
> St.Ack
>

Re: HTable.getEndKeys() returning empty results

Posted by Stack <st...@duboce.net>.
On Thu, Mar 8, 2012 at 11:50 AM, de Souza Medeiros Andre
<an...@aalto.fi> wrote:
> Or does this happen only with one-region tables?
>
Yes

> Any way, is there some way of getting the last _data_ row of a table? Other than scanning the whole thing...
>

No.

St.Ack

RE: HTable.getEndKeys() returning empty results

Posted by de Souza Medeiros Andre <an...@aalto.fi>.
Thanks for the answer.
This is quite confusing though, what is the point of having a method to retrieve the last key if we know that anyway it will be an empty byte array?

Or does this happen only with one-region tables?

Any way, is there some way of getting the last _data_ row of a table? Other than scanning the whole thing...

Thanks,
- Andre Medeiros
________________________________________
From: saint.ack@gmail.com [saint.ack@gmail.com] on behalf of Stack [stack@duboce.net]
Sent: Thursday, March 08, 2012 18:48
To: user@hbase.apache.org
Subject: Re: HTable.getEndKeys() returning empty results

On Thu, Mar 8, 2012 at 8:25 AM, de Souza Medeiros Andre
<an...@aalto.fi> wrote:
> Hi all,
>
> Has someone had problems with HTable.getEndKeys() method? In my application it returns an array of byte[], but the first (and only) byte[] is empty, so essentially it's telling me that the (single) region has no end key.
>
> The table has 3 rows and I'm running standalone HBase 0.90.4 CDH3u3 on my local machine. Moreover, the call getEndKeys() is executed immediately after I put rows in the table.
>
> Do I need to wait until the .META. table gets updated with the regions' end row keys?
> Does HTable.getEndKeys() work only in a fully distributed mode?
> Is there any other way of getting the last row in a table? (this is my objective after all)
>

An empty byte array is the last key in a table of one region only.  An
hbase table uses empty byte array as both the start and end row
signifier as per the bigtable paper (I don't see this explicitly
called out in the reference guide but I'm probably not looking in
right place).

St.Ack

Re: HTable.getEndKeys() returning empty results

Posted by Doug Meil <do...@explorysmedical.com>.
I'll make a few more links to it in the RefGuide.  This section comes up a
lot in questions.





On 3/8/12 2:11 PM, "Stack" <st...@duboce.net> wrote:

>On Thu, Mar 8, 2012 at 9:27 AM, Doug Meil <do...@explorysmedical.com>
>wrote:
>>
>> I believe that's covered here...
>>
>> http://hbase.apache.org/book.html#arch.catalog
>>
>> "Notes on HRegionInfo:  the empty key is used to denote table start and
>> table end.  A region with an empty start key
>>       is the first region in a table.  If region has both an empty start
>> and an empty end key, its the only region in the table"
>>
>>
>
>I knew it was in there.  Should we link to it over in HRegion section?
> Or a section on HRegionInfo?
>St.Ack
>



Re: HTable.getEndKeys() returning empty results

Posted by Stack <st...@duboce.net>.
On Thu, Mar 8, 2012 at 9:27 AM, Doug Meil <do...@explorysmedical.com> wrote:
>
> I believe that's covered here...
>
> http://hbase.apache.org/book.html#arch.catalog
>
> "Notes on HRegionInfo:  the empty key is used to denote table start and
> table end.  A region with an empty start key
>       is the first region in a table.  If region has both an empty start
> and an empty end key, its the only region in the table"
>
>

I knew it was in there.  Should we link to it over in HRegion section?
 Or a section on HRegionInfo?
St.Ack

Re: HTable.getEndKeys() returning empty results

Posted by Doug Meil <do...@explorysmedical.com>.
I believe that's covered here...

http://hbase.apache.org/book.html#arch.catalog

"Notes on HRegionInfo:  the empty key is used to denote table start and
table end.  A region with an empty start key
       is the first region in a table.  If region has both an empty start
and an empty end key, its the only region in the table"




On 3/8/12 11:48 AM, "Stack" <st...@duboce.net> wrote:

>On Thu, Mar 8, 2012 at 8:25 AM, de Souza Medeiros Andre
><an...@aalto.fi> wrote:
>> Hi all,
>>
>> Has someone had problems with HTable.getEndKeys() method? In my
>>application it returns an array of byte[], but the first (and only)
>>byte[] is empty, so essentially it's telling me that the (single) region
>>has no end key.
>>
>> The table has 3 rows and I'm running standalone HBase 0.90.4 CDH3u3 on
>>my local machine. Moreover, the call getEndKeys() is executed
>>immediately after I put rows in the table.
>>
>> Do I need to wait until the .META. table gets updated with the regions'
>>end row keys?
>> Does HTable.getEndKeys() work only in a fully distributed mode?
>> Is there any other way of getting the last row in a table? (this is my
>>objective after all)
>>
>
>An empty byte array is the last key in a table of one region only.  An
>hbase table uses empty byte array as both the start and end row
>signifier as per the bigtable paper (I don't see this explicitly
>called out in the reference guide but I'm probably not looking in
>right place).
>
>St.Ack
>



Re: HTable.getEndKeys() returning empty results

Posted by Stack <st...@duboce.net>.
On Thu, Mar 8, 2012 at 8:25 AM, de Souza Medeiros Andre
<an...@aalto.fi> wrote:
> Hi all,
>
> Has someone had problems with HTable.getEndKeys() method? In my application it returns an array of byte[], but the first (and only) byte[] is empty, so essentially it's telling me that the (single) region has no end key.
>
> The table has 3 rows and I'm running standalone HBase 0.90.4 CDH3u3 on my local machine. Moreover, the call getEndKeys() is executed immediately after I put rows in the table.
>
> Do I need to wait until the .META. table gets updated with the regions' end row keys?
> Does HTable.getEndKeys() work only in a fully distributed mode?
> Is there any other way of getting the last row in a table? (this is my objective after all)
>

An empty byte array is the last key in a table of one region only.  An
hbase table uses empty byte array as both the start and end row
signifier as per the bigtable paper (I don't see this explicitly
called out in the reference guide but I'm probably not looking in
right place).

St.Ack