TECH SOLUTIONS

Click here to edit subtitle

Forums

Post Reply
Forum Home > Bigdata Learnings( Hadoop, HBase,Hive and other bigdata technologies) > HBase: Basic Filter Example (RowFilter)

Sourav Gulati
Site Owner
Posts: 83

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.


Click here for Other topics of BigData Technologies

February 11, 2013 at 4:24 AM Flag Quote & Reply

You must login to post.