Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
HBase, mail # user - Re: HBase - Secondary Index

anil gupta 2012-12-14, 08:41
Anoop Sam John 2012-12-14, 08:54
ramkrishna vasudevan 2012-12-14, 11:34
anil gupta 2012-12-14, 18:01
Copy link to this message
RE: HBase - Secondary Index
Anoop Sam John 2012-12-17, 04:02
Hi Anil
                During the scan, there is no need to fetch any index data to client side. So there is no need to create any scanner on the index table at the client side. This happens at the server side.

For the Scan on the main table with condition on timestamp and customer id, a scanner to be created with Filters. Yes like normal when there is no secondary index. So this scan from the client will go through all the regions in the main table. When it scans one particular region say (x,y] on the main table, using the CP we can get the index table region object corresponding to this main table region from the RS.  There is no issue in creating the static part of the rowkey. You know 'x' is the region start key. Then at the server side will create a scanner on the index region directly and here we can specify the startkey. 'x' + <timestamp value> + <customer id>..  Using the results from the index scan we will make reseek on the main region to the exact rows where the data what we are interested in is available. So there wont be a full region data scan happening.  

When in the cases where only timestamp is there but no customer id, it will be simple again. Create a scanner on the main table with only one filter. At the CP side the scanner on the index region will get created with startkey as 'x' + <timestamp value>..    When you create the scan object and set startRow on that it need not be the full rowkey. It can be part of the rowkey also. Yes like prefix.

Hope u got it now :)

From: anil gupta [[EMAIL PROTECTED]]
Sent: Friday, December 14, 2012 11:31 PM
Subject: Re: HBase - Secondary Index

On Fri, Dec 14, 2012 at 12:54 AM, Anoop Sam John <[EMAIL PROTECTED]> wrote:

> Hi Anil,
> >1. In your presentation you mentioned that region of Primary Table and
> Region of Secondary Table are always located on the same region server. How
> do you achieve it? By using the Primary table rowkey as prefix of  Rowkey
> of Secondary Table? Will your implementation work if the rowkey of primary
> table cannot be used as prefix in rowkey of Secondary table( i have this
> limitation in my use case)?
> First all there will be same number of regions in both primary and index
> tables. All the start/stop keys of the regions also will be same.
> Suppose there are 2 regions on main table say for keys 0-10 and 10-20.
>  Then we will create 2 regions in index table also with same key ranges.
> At the master balancing level it is easy to collocate these regions seeing
> the start and end keys.
> When the selection of the rowkey that will be used in the index table is
> the key here.
> What we will do is all the rowkeys in the index table will be prefixed
> with the start key of the region/
> When an entry is added to the main table with rowkey as 5 it will go to
> the 1st region (0-10)
> Now there will be index region with range as 0-10.  We will select this
> region to store this index data.
> The row getting added into the index region for this entry will have a
> rowkey 0_x_5
> I am just using '_' as a seperator here just to show this. Actually we
> wont be having any seperator.
> So the rowkeys (in index region) will have a static begin part always.
>  Will scan time also we know this part and so the startrow and endrow
> creation for the scan will be possible.. Note that we will store the actual
> table row key as the last part of the index rowkey itself not as a value.
> This is better option in our case of handling the scan index usage also at
> sever side.  There is no index data fetch to client side..

Anil: My primary table rowkey is customerId+event_id, and my secondary
table rowkey is timestamp+ customerid. In your implementation it seems like
for using secondary index the application needs to know about the
"start_key" of the region(static begin part) it wants to query. Right? Do
you separately manage the logic of determining the region
"start_key"(static begin part) for a scan?
Also, Its possible that while using secondary index the customerId is not
provided. So, i wont be having customer id for all the queries. Hence i
cannot use customer_id as a prefix in rowkey of my Secondary Table.

Anil: Somehow i am unable to fit your implementation into my use case due
to the constraint of static begin part of rowkey in Secondary table. There
seems to be a disconnect. Can you tell me how does my use case fits into
your implementation?
Thanks & Regards,
Anil Gupta
anil gupta 2012-12-18, 08:28
Anoop Sam John 2012-12-18, 09:27
anil gupta 2012-12-19, 08:24
Michel Segel 2012-12-18, 09:02
Anoop Sam John 2012-12-18, 09:35
anil gupta 2012-12-19, 08:39
Shengjie Min 2012-12-27, 11:23
Anoop Sam John 2012-12-27, 11:30
Shengjie Min 2012-12-27, 13:07
Anoop John 2012-12-27, 15:54
ramkrishna vasudevan 2012-12-27, 16:11
Shengjie Min 2012-12-27, 16:29
Anoop Sam John 2012-12-28, 03:33
Mohit Anchlia 2012-12-28, 03:42
Anoop Sam John 2012-12-28, 04:14
Shengjie Min 2012-12-28, 10:55
Adrien Mogenet 2013-01-06, 20:30
Anoop Sam John 2013-01-07, 03:48
Mohit Anchlia 2013-01-07, 04:17
Anoop Sam John 2013-01-07, 13:49
Michael Segel 2013-01-08, 14:33
lars hofhansl 2013-01-09, 00:30
Michel Segel 2013-01-09, 01:30
anil gupta 2013-01-09, 01:28
Anoop Sam John 2013-01-09, 03:22
ramkrishna vasudevan 2013-01-09, 04:11
Mohit Anchlia 2013-01-09, 01:50
Asaf Mesika 2013-01-08, 23:00
Mohit Anchlia 2013-01-06, 20:36
Adrien Mogenet 2013-01-06, 20:40
anil gupta 2013-01-06, 22:12
Anoop Sam John 2012-12-20, 03:33
Farah Karim 2012-12-25, 10:14
David Arthur 2012-12-20, 02:47
Anoop Sam John 2012-12-20, 03:44