简体   繁体   中英

Hbase filter to find rows without a specific column

I want to filter out all rows that do not have a specific column. any idea which comparator to use?

You can use skip filter combined with qualifier filter . If you use the java client API:

Filter filter = new QualifierFilter(CompareFilter.CompareOp.EQUAL,new BinaryComparator(Bytes.toBytes("column-name")));
Filter filter2 = new SkipFilter(filter);
scan.setFilter(filter2);

this will return all the row without that specific column

SingleColumnValueFilter has method setFilterIfMissing that excludes all row that do not contain given column if it is given true . All that is needed is to design filter so it will always pass and call setFilterIfMissing(true)

    SingleColumnValueFilter filter = new  SingleColumnValueFilter(Bytes.toBytes(columnFamily), Bytes.toBytes("column_name"), CompareFilter.CompareOp.NOT_EQUAL, Bytes.toBytes("non-sense"));
    filter.setFilterIfMissing(true);
    scan.setFilter(filter);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM