public class FilterExample {
public static void main(String[] args) throws IOException
{
Configuration conf = HBaseConfiguration.create();
HTable table = new HTable(conf,"employee");
Scan scan = new Scan();
Filter filter = new RowFilter(CompareFilter.CompareOp.LESS_OR_EQUAL, new BinaryComparator(Bytes.toBytes("3")));
scan.setFilter(filter);
ResultScanner scanner = table.getScanner(scan);
for ( Result res: scanner)
{
for (KeyValue kv: res.raw())
{
System.out.println("Row is"+" "+Bytes.toString(kv.getRow()));
System.out.println("Family is"+" "+Bytes.toString(kv.getFamily()) );
System.out.println("Qualifir is "+" "+Bytes.toString(kv.getQualifier()) );
System.out.println("Value is"+" "+Bytes.toString(kv.getValue()) );
}
}
scanner.close();
}
}
Also FamilyFilter,QualifierFilter,ValueFilter works similarly.
No comments:
Post a Comment