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

Switch to Plain View
HBase, mail # user - problem with fliter in scan


+
jian fan 2012-10-26, 01:54
Copy link to this message
-
RE: problem with fliter in scan
Anoop Sam John 2012-10-26, 04:18

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 [[EMAIL PROTECTED]]
Sent: Friday, October 26, 2012 7:24 AM
To: [EMAIL PROTECTED]
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
+
jian fan 2012-10-26, 06:29