Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> problem with fliter in scan


Copy link to this message
-
RE: problem with fliter in scan

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
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB