I have a Hbase
"User" table. Now I have the row keys of User table but I want to get only those user whose dateOfBirth
is grater then a "Valid Date" and belongs to the key List.
Currently I am using
Result[] result = table.get(keys);
for getting all users whose keys I have.
I am new in Hbase
. Please help.
Thanks
You can try something like this:
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
FilterList fl = new FilterList();
Filter filter = new SingleColumnValueFilter(Bytes.toBytes("columnFamily"), Bytes.toBytes("column"), CompareFilter.CompareOp.GREATER, Bytes.toBytes(dateOfBirth));
fl.add(filter);
scan.setFilter(fl);
ResultScanner rs = table.getScanner(scan);
You can get more info about filters in http://hbase.apache.org/book/client.filter.html
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.