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() {
            /*
            * 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);

            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();
                  }
            }

      }

First few records of the table are :

O12004457;C110;P60337998;2000-5-17;16;19184.0;cash;Customer is the new emperor. 
Either you give him what he desires or you are
banished from his kingdom.;Before you place your order, we reserve the right 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 
substitute goods.Our VAT registration number is 875 505
5 01.;

O12004458;C425;P50478434;2008-4-30;3;831825.0;debit;In times of change, the 
learners will inherit the earth, while the knowers
will find themselves beautifully equipped to deal with a world that no longer 
exists;Before you place your order, we reserve
the right to change these terms and conditions at any time.Any such changes 
will take effect when posted on this website and i
t is your responsibility to read these terms and conditions on each occasion 
you use this website. We will never supply you wi
th substitute goods.Our VAT registration number is 875 5055 01.;



If I don't use any filter, the row that I'm trying to fetch is returned along 
with the 1000s of others but as soon as I use even a single filter(the other is 
commented), no results are returned.

Is there some problem with my code?

Regards,
Omkar Joshi


________________________________
The contents of this e-mail and any attachment(s) may contain confidential or 
privileged information for the intended recipient(s). Unintended recipients are 
prohibited from taking action on the basis of information in this e-mail and 
using or disseminating the information, and must notify the sender and delete 
it from their system. L&T Infotech will not accept responsibility or liability 
for the accuracy or completeness of, or the presence of any virus or disabling 
code in this e-mail"

Reply via email to