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 2BE59F3BC for ; Wed, 17 Apr 2013 13:29:33 +0000 (UTC) Received: (qmail 50128 invoked by uid 500); 17 Apr 2013 13:29:31 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 49307 invoked by uid 500); 17 Apr 2013 13:29:30 -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 49299 invoked by uid 99); 17 Apr 2013 13:29:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Apr 2013 13:29:30 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [216.82.254.112] (HELO mail1.bemta7.messagelabs.com) (216.82.254.112) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Apr 2013 13:29:24 +0000 Received: from [216.82.254.20:7067] by server-16.bemta-7.messagelabs.com id 5A/E2-01807-F93AE615; Wed, 17 Apr 2013 13:29:03 +0000 X-Env-Sender: Omkar.Joshi@lntinfotech.com X-Msg-Ref: server-12.tower-47.messagelabs.com!1366205340!1819628!1 X-Originating-IP: [203.199.118.205] X-StarScan-Received: X-StarScan-Version: 6.8.6.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12347 invoked from network); 17 Apr 2013 13:29:02 -0000 Received: from unknown (HELO VSHINMSHTCAS01.vshodc.lntinfotech.com) (203.199.118.205) by server-12.tower-47.messagelabs.com with AES128-SHA encrypted SMTP; 17 Apr 2013 13:29:02 -0000 Received: from vshinmsmbx01.vshodc.lntinfotech.com ([172.17.24.118]) by VSHINMSHTCAS01.vshodc.lntinfotech.com ([172.17.24.112]) with mapi; Wed, 17 Apr 2013 18:57:34 +0530 From: Omkar Joshi To: "user@hbase.apache.org" Date: Wed, 17 Apr 2013 18:57:31 +0530 Subject: RE: Problem in filters Thread-Topic: Problem in filters Thread-Index: Ac47btKQDV+vw465R5KDIlHUQBQqhAAAFdCg Message-ID: References: <0A723D51-3FCA-491A-A1AD-16F21AA3171C@gmail.com> In-Reply-To: <0A723D51-3FCA-491A-A1AD-16F21AA3171C@gmail.com> 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 Ted, I tried using only productIdFilter without FilterList but still no output. public void executeOrdersQuery() { /* * SELECT ORDER_ID,CUSTOMER_ID,PRODUCT_ID,QUANTITY FROM ORDERS WHERE * QUANTITY >=3D16 and PRODUCT_ID=3D'P60337998' */ String tableName =3D "ORDERS"; String family =3D "ORDER_DETAILS"; int quantity =3D 16; String productId =3D "P60337998"; SingleColumnValueFilter quantityFilter =3D new SingleColumnValueFilter( Bytes.toBytes(family), Bytes.toBytes("PRODUCT_QUANTITY"), CompareFilter.CompareOp.GREATER_OR_EQUAL, Bytes.toBytes(quantity)); SingleColumnValueFilter productIdFilter =3D new SingleColumnValueFilter( Bytes.toBytes(family), Bytes.toBytes("PRODUCT_ID"), CompareFilter.CompareOp.EQUAL, Bytes.toBytes(productId)); FilterList filterList =3D new FilterList( FilterList.Operator.MUST_PASS_ALL); // filterList.addFilter(quantityFilter); filterList.addFilter(productIdFilter); Scan scan =3D new Scan(); scan.addColumn(Bytes.toBytes(family), Bytes.toBytes("ORDER_ID")); scan.addColumn(Bytes.toBytes(family), Bytes.toBytes("CUSTOMER_ID")); scan.addColumn(Bytes.toBytes(family), Bytes.toBytes("PRODUCT_ID")); scan.addColumn(Bytes.toBytes(family), Bytes.toBytes("QUANTITY")); // scan.setFilter(filterList); scan.setFilter(productIdFilter); HTableInterface tbl =3D hTablePool.getTable(Bytes.toBytes(tableName)); ResultScanner scanResults =3D null; try { scanResults =3D tbl.getScanner(scan); System.out.println("scanResults : "); for (Result result : scanResults) { System.out.println("The result is " + result); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { tbl.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } Regards, Omkar Joshi -----Original Message----- From: Ted Yu [mailto:yuzhihong@gmail.com]=20 Sent: Wednesday, April 17, 2013 6:46 PM To: user@hbase.apache.org Cc: user@hbase.apache.org Subject: Re: Problem in filters If you specify producIdFilter without using FilterList, what would you get = ? Thanks On Apr 17, 2013, at 4:51 AM, Omkar Joshi wrot= e: > Hi, >=20 > I'm having the a table named ORDERS with 1000851 rows: >=20 > rowkey : ORDER_ID >=20 > column family : ORDER_DETAILS > columns : CUSTOMER_ID > PRODUCT_ID > REQUEST_DATE > PRODUCT_QUANTITY > PRICE > PAYMENT_MODE >=20 > I'm using the following code to access the data : >=20 > public void executeOrdersQuery() { > /* > * SELECT ORDER_ID,CUSTOMER_ID,PRODUCT_ID,QUANTITY FROM ORDERS = WHERE > * QUANTITY >=3D16 and PRODUCT_ID=3D'P60337998' > */ > String tableName =3D "ORDERS"; >=20 > String family =3D "ORDER_DETAILS"; > int quantity =3D 16; > String productId =3D "P60337998"; >=20 > SingleColumnValueFilter quantityFilter =3D new SingleColumnVal= ueFilter( > Bytes.toBytes(family), Bytes.toBytes("PRODUCT_QUAN= TITY"), > CompareFilter.CompareOp.GREATER_OR_EQUAL, > Bytes.toBytes(quantity)); >=20 > SingleColumnValueFilter productIdFilter =3D new SingleColumnVa= lueFilter( > Bytes.toBytes(family), Bytes.toBytes("PRODUCT_ID")= , > CompareFilter.CompareOp.EQUAL, Bytes.toBytes(produ= ctId)); >=20 > FilterList filterList =3D new FilterList( > FilterList.Operator.MUST_PASS_ALL); > // filterList.addFilter(quantityFilter); > filterList.addFilter(productIdFilter); >=20 > Scan scan =3D new Scan(); > scan.addColumn(Bytes.toBytes(family), Bytes.toBytes("ORDER_ID"= )); > scan.addColumn(Bytes.toBytes(family), Bytes.toBytes("CUSTOMER_= ID")); > scan.addColumn(Bytes.toBytes(family), Bytes.toBytes("PRODUCT_I= D")); > scan.addColumn(Bytes.toBytes(family), Bytes.toBytes("QUANTITY"= )); >=20 > scan.setFilter(filterList); >=20 > HTableInterface tbl =3D hTablePool.getTable(Bytes.toBytes(tabl= eName)); > ResultScanner scanResults =3D null; > try { > scanResults =3D tbl.getScanner(scan); >=20 > System.out.println("scanResults : "); >=20 > for (Result result : scanResults) { > System.out.println("The result is " + result); > } >=20 > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } finally { > try { > tbl.close(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } >=20 > } >=20 > First few records of the table are : >=20 > O12004457;C110;P60337998;2000-5-17;16;19184.0;cash;Customer is the new em= peror. Either you give him what he desires or you are > banished from his kingdom.;Before you place your order, we reserve the ri= ght to change these terms and conditions at any time > .Any such changes will take effect when posted on this website and it is = your responsibility to read these terms and condition > s on each occasion you use this website. We will never supply you with su= bstitute goods.Our VAT registration number is 875 505 > 5 01.; >=20 > O12004458;C425;P50478434;2008-4-30;3;831825.0;debit;In times of change, t= he learners will inherit the earth, while the knowers > will find themselves beautifully equipped to deal with a world that no lo= nger exists;Before you place your order, we reserve > the right to change these terms and conditions at any time.Any such chang= es will take effect when posted on this website and i > t is your responsibility to read these terms and conditions on each occas= ion you use this website. We will never supply you wi > th substitute goods.Our VAT registration number is 875 5055 01.; >=20 >=20 >=20 > If I don't use any filter, the row that I'm trying to fetch is returned a= long with the 1000s of others but as soon as I use even a single filter(the= other is commented), no results are returned. >=20 > Is there some problem with my code? >=20 > Regards, > Omkar Joshi >=20 >=20 > ________________________________ > The contents of this e-mail and any attachment(s) may contain confidentia= l or privileged information for the intended recipient(s). Unintended recip= ients are prohibited from taking action on the basis of information in this= e-mail and using or disseminating the information, and must notify the sen= der and delete it from their system. L&T Infotech will not accept responsib= ility or liability for the accuracy or completeness of, or the presence of = any virus or disabling code in this e-mail"