简体   繁体   中英

Scan Hbase for particular rowkey's

I want to get all columns from Hbase table within particular Rowkey.

eg:
 Rowkey starts from 123456
 Rowkey ends with 123466

so i want to fetch programatically (In java) all columns  within this rowkeym only.

This is quite straight forward. Have you tried anything? Anyways,

Configuration conf = HbaseConfiguration.create();
HTable table = new HTable(conf, "tablename");
Scan scan = new Scan();
scan.setStartRow(Bytes.toBytes("123456"));
scan.setStopRow(Bytes.toBytes("123456"));
ResultScanner rs = table.getScanner();
for (Result result : scanner) {
     for (KeyValue kv : result.raw()) {
        System.out.println("KV: " + kv + ", Value: " +
        Bytes.toString(kv.getValue()));
     }
}
scanner.close();    

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM