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 EAF998B51 for ; Tue, 30 Aug 2011 03:51:42 +0000 (UTC) Received: (qmail 36697 invoked by uid 500); 30 Aug 2011 03:51:41 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 36066 invoked by uid 500); 30 Aug 2011 03:51:34 -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 36057 invoked by uid 99); 30 Aug 2011 03:51:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Aug 2011 03:51:28 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of stutiawasthi@hcl.com designates 203.105.185.23 as permitted sender) Received: from [203.105.185.23] (HELO gws05.hcl.com) (203.105.185.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Aug 2011 03:51:21 +0000 Received: from NDA-HCLIN-HT01.CORP.HCL.IN (10.248.64.35) by NDA-HCLIN-EDGE3.hcl.in (10.248.64.140) with Microsoft SMTP Server id 8.2.254.0; Tue, 30 Aug 2011 09:21:24 +0530 Received: from NDA-HCLC-HT02.HCLC.CORP.HCL.IN (10.33.64.134) by NDA-HCLIN-HT01.CORP.HCL.IN (10.248.64.35) with Microsoft SMTP Server (TLS) id 8.2.254.0; Tue, 30 Aug 2011 09:20:43 +0530 Received: from NDA-HCLC-EVS04.HCLC.CORP.HCL.IN ([10.33.64.194]) by NDA-HCLC-HT02.HCLC.CORP.HCL.IN ([::1]) with mapi; Tue, 30 Aug 2011 09:20:43 +0530 From: Stuti Awasthi To: "user@hbase.apache.org" Date: Tue, 30 Aug 2011 09:20:42 +0530 Subject: RE: Scan not working properly on composite keys Thread-Topic: Scan not working properly on composite keys Thread-Index: AcxmZOPOy150xh7pRDGx8gtUsHPhhwAYwTmg Message-ID: <7D9AF4B98807C54EBADEA75DF6D5ACB7951BE8@NDA-HCLC-EVS04.HCLC.CORP.HCL.IN> References: <7D9AF4B98807C54EBADEA75DF6D5ACB7951959@NDA-HCLC-EVS04.HCLC.CORP.HCL.IN> <2D6136772A13B84E95DF6DA79E85A9F00158E398C204@NSPEXMBX-A.the-lab.llnl.gov> <7D9AF4B98807C54EBADEA75DF6D5ACB7951B7B@NDA-HCLC-EVS04.HCLC.CORP.HCL.IN> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org Hi Ian, Thanks for explaining this. :) -----Original Message----- From: Ian Varley [mailto:ivarley@salesforce.com]=20 Sent: Monday, August 29, 2011 9:31 PM To: user@hbase.apache.org Subject: Re: Scan not working properly on composite keys Stuti, The rows are physically sorted on disk (and in memory) according to the row= keys you define, and that's the only way that HBase can access them (unlik= e a relational database, it doesn't have built in indexes that allow you to= access rows by something other than their physical sort order). So having = a general wildcard lookup feature wouldn't be practical; in reality, it wou= ld have to scan ever row in the table to see which ones match your pattern.= =20 That said, you could build a little wrapper on top of your access code as f= ollows (pseudocode): function getRowsByUser(string user) { prefixes =3D "admin", "viewer", "etc"; for each prefix in prefixes { result.add(getRowsFromHBase(prefix + user)); } return result; } That way, at least your scan is linear in the number of prefixes--it just d= oes one constant-time seek to the start of the rows for the given user, for= each of the prefixes you know about. You can't expect functionality like this to be built in to HBase, because t= o HBase, row keys are simply byte arrays, nothing more. It does nothing to = enforce structure on them, that's entirely your application's job. Ian On Aug 29, 2011, at 10:49 AM, Stuti Awasthi wrote: > Hi, >=20 > Sure, I tried also by prefixing with admin, and it was working fine. I wa= s just wondering that is there any way that we can get the information from= Hbase using some part of Composite keys or wild card characters ? >=20 > Thanks >=20 > -----Original Message----- > From: Buttler, David [mailto:buttler1@llnl.gov]=20 > Sent: Monday, August 29, 2011 8:46 PM > To: user@hbase.apache.org > Subject: RE: Scan not working properly on composite keys >=20 > The scan started at "viewer/user3" because that is the next key after "us= er2". If your keys have a prefix, like admin or viewer, then you need to p= repend that to your start row as well. Hbase has no magic where it can int= uit your intent. >=20 > Dave >=20 > -----Original Message----- > From: Stuti Awasthi [mailto:stutiawasthi@hcl.com] > Sent: Monday, August 29, 2011 12:39 AM > To: user@hbase.apache.org > Subject: Scan not working properly on composite keys >=20 > Hi Friends, >=20 > I have a query regarding scan operation on composite keys. >=20 > I have table as follows : >=20 > admin/user1 column=3Dinfo:email, ti= mestamp=3D1314594930540, value=3Dabc > admin/ user1 column=3Dinfo:mobile, tim= estamp=3D1314594940686, value=3D123456 > admin/ user1 column=3Dinfo:name, times= tamp=3D1314594915091, value=3Ddef > admin/user2 column=3Dinfo:email, time= stamp=3D1314597627865, value=3Ddef > admin/ user2 column=3Dinfo:mobile, tim= estamp=3D1314597636663, value=3D67890 > admin/ user2 column=3Dinfo:name, times= tamp=3D1314597614585, value=3Dpqr > viewer/user3 column=3Dinfo:email, tim= estamp=3D1314601194373, value=3Dpqr > viewer/ user3 column=3Dinfo:mobile, ti= mestamp=3D1314601256479, value=3D12345 > viewer/ user3 column=3Dinfo:name, times= tamp=3D1314601207662, value=3Dxyz >=20 > I want to find all the records of "user2". For this I tried following que= ry but it is giving me all records of user3 : >=20 > hbase(main):005:0> scan 'users', {STARTROW=3D>'user2'} > ROW COLUMN+CELL > viewer/user3 column=3Dinfo:email, timestamp=3D13= 14601194373, value=3Dsatyendrap@hcl.com > viewer/ user3 column=3Dinfo:mobile, timestamp=3D= 1314601256479, value=3D37498734893 > viewer/ user3 column=3Dinfo:name, timestamp=3D13= 14601207662, value=3Dsatyendra pandey > 1 row(s) in 0.0330 seconds >=20 > I also tried various queries for this but not getting correct result. I a= m definitely missing something. Please help >=20 > Thanks & Regards > Stuti Awasthi > Sr Specialist >=20 >=20 > ________________________________ > ::DISCLAIMER:: > -------------------------------------------------------------------------= ---------------------------------------------- >=20 > The contents of this e-mail and any attachment(s) are confidential and in= tended for the named recipient(s) only. > It shall not attach any liability on the originator or HCL or its affilia= tes. Any views or opinions presented in this email are solely those of the = author and may not necessarily reflect the opinions of HCL or its affiliate= s. > Any form of reproduction, dissemination, copying, disclosure, modificatio= n, distribution and / or publication of this message without the prior writ= ten consent of the author of this e-mail is strictly prohibited. If you hav= e received this email in error please delete it and notify the sender immed= iately. Before opening any mail and attachments please check them for virus= es and defect. >=20 > -------------------------------------------------------------------------= ----------------------------------------------