Return-Path: X-Original-To: apmail-hbase-user-archive@www.apache.org Delivered-To: apmail-hbase-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3D56BD695 for ; Fri, 26 Oct 2012 04:35:42 +0000 (UTC) Received: (qmail 17578 invoked by uid 500); 26 Oct 2012 04:35:39 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 17508 invoked by uid 500); 26 Oct 2012 04:35:38 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 17478 invoked by uid 99); 26 Oct 2012 04:35:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Oct 2012 04:35:37 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of anoopsj@huawei.com designates 119.145.14.64 as permitted sender) Received: from [119.145.14.64] (HELO szxga01-in.huawei.com) (119.145.14.64) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Oct 2012 04:35:31 +0000 Received: from 172.24.2.119 (EHLO szxeml205-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id ARH84790; Fri, 26 Oct 2012 12:35:08 +0800 (CST) Received: from SZXEML418-HUB.china.huawei.com (10.82.67.157) by szxeml205-edg.china.huawei.com (172.24.2.58) with Microsoft SMTP Server (TLS) id 14.1.323.3; Fri, 26 Oct 2012 12:33:42 +0800 Received: from SZXEML531-MBX.china.huawei.com ([fe80::61a8:2cb5:62f9:d4a4]) by szxeml418-hub.china.huawei.com ([10.82.67.157]) with mapi id 14.01.0323.003; Fri, 26 Oct 2012 12:33:42 +0800 From: Anoop Sam John To: "user@hbase.apache.org" Subject: RE: Best technique for doing lookup with Secondary Index Thread-Topic: Best technique for doing lookup with Secondary Index Thread-Index: AQHNsjBOGNa6zWdMZUywxBtWv7V3ZZfJcgx/gAEk1Sj//+ESAIAAiX85 Date: Fri, 26 Oct 2012 04:33:41 +0000 Message-ID: <0CE69E9126D0344088798A3B7F7F80863A4F1E81@szxeml531-mbx.china.huawei.com> References: <0CE69E9126D0344088798A3B7F7F80863A4F16AB@szxeml531-mbx.china.huawei.com> <5088cb63.c5d1440a.6c6e.ffffe535SMTPIN_ADDED@mx.google.com> ,<008f01cdb331$39023db0$ab06b910$@vasudevan@huawei.com> In-Reply-To: <008f01cdb331$39023db0$ab06b910$@vasudevan@huawei.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.18.96.95] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Virus-Checked: Checked by ClamAV on apache.org Anil Have a look at MultiTableOutputFormat ( I am refering to 0.94 code bas= e Not sure whether available in older versions) -Anoop- ________________________________________ From: Ramkrishna.S.Vasudevan [ramkrishna.vasudevan@huawei.com] Sent: Friday, October 26, 2012 9:50 AM To: user@hbase.apache.org Subject: RE: Best technique for doing lookup with Secondary Index > Is it a > good idea to create Htable instance on "B" and do put in my mapper? I > might > try this idea. Yes you can do this.. May be the same mapper you can do a put for table "B". This was how we have tried loading data to another table by using the main table "A" Puts. Now your main question is lookups right Now there are some more hooks in the scan flow called pre/postScannerOpen, pre/postScannerNext. May be you can try using them to do a look up on the secondary table and then use those values and pass it to the main table next(). But this may involve more RPC calls as your regions of "A" and "B" may be i= n different RS. If something is wrong in my understanding of what you said, kindly spare me= . :) Regards Ram > -----Original Message----- > From: anil gupta [mailto:anilgupta84@gmail.com] > Sent: Friday, October 26, 2012 3:40 AM > To: user@hbase.apache.org > Subject: Re: Best technique for doing lookup with Secondary Index > > Anoop: In prePut hook u call HTable#put()? > Anil: Yes i call HTable#put() in prePut. Is there better way of doing > it? > > Anoop: Why use the network calls from server side here then? > Anil: I thought this is a cleaner approach since i am using BulkLoader. > I > decided not to run two jobs since i am generating a UniqueIdentifier at > runtime in bulkloader. > > Anoop: can not handle it from client alone? > Anil: I cannot handle it from client since i am using BulkLoader. Is it > a > good idea to create Htable instance on "B" and do put in my mapper? I > might > try this idea. > > Anoop: You can have a look at Lily project. > Anil: It's little late for us to evaluate Lily now and at present we > dont > need complex secondary index since our data is immutable. > > Ram: what is rowkey B here? > Anil: Suppose i am storing customer events in table A. I have two > requirement for data query: > 1. Query customer events on basis of customer_Id and event_ID. > 2. Query customer events on basis of event_timestamp and customer_ID. > > 70% of querying is done by query#1, so i will create > as row key of Table A. > Now, in order to support fast results for query#2, i need to create a > secondary index on A. I store that secondary index in B, rowkey of B is > .Every row stores the corresponding > rowkey > of A. > > Ram:How is the startRow determined for every query? > Anil: Its determined by a very simple application logic. > > Thanks, > Anil Gupta > > On Wed, Oct 24, 2012 at 10:16 PM, Ramkrishna.S.Vasudevan < > ramkrishna.vasudevan@huawei.com> wrote: > > > Just out of curiosity, > > > The secondary index is stored in table "B" as rowkey B --> > > > family: > > A> > > what is rowkey B here? > > > 1. Scan the secondary table by using prefix filter and startRow. > > How is the startRow determined for every query ? > > > > Regards > > Ram > > > > > -----Original Message----- > > > From: Anoop Sam John [mailto:anoopsj@huawei.com] > > > Sent: Thursday, October 25, 2012 10:15 AM > > > To: user@hbase.apache.org > > > Subject: RE: Best technique for doing lookup with Secondary Index > > > > > > >I build the secondary table "B" using a prePut RegionObserver. > > > > > > Anil, > > > In prePut hook u call HTable#put()? Why use the network > calls > > > from server side here then? can not handle it from client alone? > You > > > can have a look at Lily project. Thoughts after seeing ur idea on > put > > > and scan.. > > > > > > -Anoop- > > > ________________________________________ > > > From: anil gupta [anilgupta84@gmail.com] > > > Sent: Thursday, October 25, 2012 3:10 AM > > > To: user@hbase.apache.org > > > Subject: Best technique for doing lookup with Secondary Index > > > > > > Hi All, > > > > > > I am using HBase 0.92.1. I have created a secondary index on table > "A". > > > Table A stores immutable data. I build the secondary table "B" > using a > > > prePut RegionObserver. > > > > > > The secondary index is stored in table "B" as rowkey B --> > > > family: > > A> . "" is the column qualifier. Every row in B will > only on > > > have one column and the name of that column is the rowkey of A. So > the > > > value is blank. As per my understanding, accessing column qualifier > is > > > faster than accessing value. Please correct me if i am wrong. > > > > > > > > > HBase Querying approach: > > > 1. Scan the secondary table by using prefix filter and startRow. > > > 2. Do a batch get on primary table by using HTable.get(List) > > > method. > > > > > > The above approach for retrieval works fine but i was wondering it > > > there is > > > a better approach. I was planning to try out doing the retrieval > using > > > coprocessors. > > > Have anyone tried using coprocessors? I would appreciate if others > can > > > share their experience with secondary index for HBase queries. > > > > > > -- > > > Thanks & Regards, > > > Anil Gupta=3D > > > > > > > -- > Thanks & Regards, > Anil Gupta=