首页 > 代码库 > hbase过滤器(1)
hbase过滤器(1)
最近在公司做hbase就打算复习下它的过滤器以便不时之需,RowFilter根据行键(rowkey)筛选数据
public void filter() throws IOException
{
Filter rf = new RowFilter(CompareFilter.CompareOp.LESS, new BinaryComparator(Bytes.toBytes("35643b94-b396-4cdc-abd9-029ca495769d")));
Scan s = new Scan();
s.setFilter(rf);
ResultScanner rs = table.getScanner(s);
for (Result r : rs) {
System.out.println("rowkey:" + new String(r.getRow()));
for (KeyValue keyValue : r.raw()) {
System.out.println("列族:" + new String(keyValue.getFamily())
+ " 列:" + new String(keyValue.getQualifier()) + ":"
+ new String(keyValue.getValue()));
}
}
}
hbase过滤器(1)