Thursday 2 May 2013

HBase: Scanner Example( Scanning selective rows from table)


public class ScanExample {
    public static void main(String[] args) throws IOException
    {
        Configuration conf = HBaseConfiguration.create();
        HTable table = new HTable(conf, "employee");
        Scan scan = new Scan();
        scan.setStartRow(Bytes.toBytes("2")).setStopRow(Bytes.toBytes("4"));
        
        ResultScanner scanner = table.getScanner(scan);
        for (Result res: scanner)
        {
            System.out.println(res);
        }
        
        scanner.close();
        
        
    }
       
}

No comments:

Post a Comment