How to use "multiple AND in columns" to filter the row in hbase?

538 views Asked by At

The scenario like this: In a hbase table, there are different columns for different rows, e.g.: row1 have columns fm:a, fm:b, fm:c row2 have columns fm:a, fm:d

So I want to use a scan to test if a row have both column fm:a & fm:b, if so, return this row, otherwise, this row should not be returned in the scan result. In above case, I just want to row1 be returned.

I check the Filters in hbase, looks like if do this in Filter level, the performance will be bad. Any ideas?

1

There are 1 answers

0
Amit On

you need to add each column to the scan - sth like this. Create a hashTable , say ht

for each columnFamily in ht:
   { for each column in columnFamily:
     { scan.addColumn(Bytes.toBytes(columnFamily), Bytes.toBytes(column)); }
   }