hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anoop Sam John <anoo...@huawei.com>
Subject RE: problem with fliter in scan
Date Fri, 26 Oct 2012 04:18:40 GMT

Use  SingleColumnValueFilter#filterIfMissing(true)
>s.setBatch(10);
How many total columns in the Schema? When using the SingleColumnValueFilter setBatch() might
not work ou always.. FYI


-Anoop-
________________________________________
From: jian fan [xiaofanhbase@gmail.com]
Sent: Friday, October 26, 2012 7:24 AM
To: user@hbase.apache.org
Subject: problem with fliter in scan

HI:
   Guys, I have a program to filter the data by scan, the code is as
follows:

        String familyName = "data";
        String qualifierName = "speed";
        String minValue = "0";
        String maxValue = "20121016124537";
        HTablePool pool = new HTablePool(cfg, 1000);
        HTable table = (HTable) pool.getTable(tableName);
        List<Filter> filters = new ArrayList<Filter>();
        SingleColumnValueFilter minFilter = new
SingleColumnValueFilter(familyName.getBytes(), qualifierName.getBytes(),
                CompareOp.GREATER_OR_EQUAL, minValue.getBytes());
        SingleColumnValueFilter maxFilter = new
SingleColumnValueFilter(familyName.getBytes(), qualifierName.getBytes(),
                CompareOp.LESS_OR_EQUAL, maxValue.getBytes());

        filters.add(maxFilter);
        filters.add(minFilter);
        Scan s = new Scan();
        s.setCaching(10000);
        s.setBatch(10);
        FilterList fl = new FilterList( FilterList.Operator.MUST_PASS_ALL,
filters);
        s.setFilter(fl);
        ResultScanner scanner = table.getScanner(s);
            for (Result r : scanner) {
                KeyValue[] kv = r.raw();

                for (int i = 0; i < kv.length; i++) {
                    System.out.println("RowKey:"+new String(kv[i].getRow())
+ " ");
                    System.out.print(new String(kv[i].getFamily()) + ":");
                    System.out.println(new String(kv[i].getQualifier()) +
" ");
                    System.out.println("value:"+new
String(kv[i].getValue()));

                }
            }


The result is :

RowKey:020028
data:location
value:CA
RowKey:020028
data:speed
value:20121016124537

RowKey:2068098
data:location
CA


Seems that the kv without qualiter "speed" is also include in the search
result, how to slove the problem?

Thanks

Jian Fan
Mime
View raw message