2013-05-14 71 views
0

我想从特定Rowkey中的Hbase表中获取所有列。扫描特定rowkey的Hbase

eg: 
Rowkey starts from 123456 
Rowkey ends with 123466 

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

回答

1

这很直截了当。你有尝试过什么吗?无论如何,

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();  
+0

谢谢塔里克:) – 2013-05-15 10:18:23