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

Switch to Plain View
HBase, mail # user - Problem in filters


+
Omkar Joshi 2013-04-17, 11:51
+
Ted Yu 2013-04-17, 13:16
+
Omkar Joshi 2013-04-17, 13:27
Copy link to this message
-
Re: Problem in filters
Jean-Marc Spaggiari 2013-04-17, 13:32
Hi Omkar,

Using the shell, can you scan the few first lines from your table to make
sure it's store with the expected format? Don't forget the limit the number
of rows retrieved.

JM
2013/4/17 Omkar Joshi <[EMAIL PROTECTED]>

> 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 >=16 and PRODUCT_ID='P60337998'
>                  */
>                 String tableName = "ORDERS";
>
>                 String family = "ORDER_DETAILS";
>                 int quantity = 16;
>                 String productId = "P60337998";
>
>                 SingleColumnValueFilter quantityFilter = new
> SingleColumnValueFilter(
>                                 Bytes.toBytes(family),
> Bytes.toBytes("PRODUCT_QUANTITY"),
>                                 CompareFilter.CompareOp.GREATER_OR_EQUAL,
>                                 Bytes.toBytes(quantity));
>
>                 SingleColumnValueFilter productIdFilter = new
> SingleColumnValueFilter(
>                                 Bytes.toBytes(family),
> Bytes.toBytes("PRODUCT_ID"),
>                                 CompareFilter.CompareOp.EQUAL,
> Bytes.toBytes(productId));
>
>                 FilterList filterList = new FilterList(
>                                 FilterList.Operator.MUST_PASS_ALL);
>                 // filterList.addFilter(quantityFilter);
>                 filterList.addFilter(productIdFilter);
>
>                 Scan scan = 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 > hTablePool.getTable(Bytes.toBytes(tableName));
>                 ResultScanner scanResults = null;
>                 try {
>                         scanResults = 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:[EMAIL PROTECTED]]
> Sent: Wednesday, April 17, 2013 6:46 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> 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 <[EMAIL PROTECTED]>
> wrote:
>
> > Hi,
> >
> > I'm having the a table named ORDERS with 1000851 rows:
> >
> > rowkey :                       ORDER_ID
> >
> > column family : ORDER_DETAILS
> >            columns : CUSTOMER_ID
> >                                    PRODUCT_ID
> >                                    REQUEST_DATE
> >                                    PRODUCT_QUANTITY
> >                                    PRICE
> >                                    PAYMENT_MODE
> >
> > I'm using the following code to access the data :
> >
> > public void executeOrdersQuery() {
+
Ian Varley 2013-04-17, 16:15
+
Omkar Joshi 2013-04-19, 09:59