问题描述
- hbase的rowkey问题?????
-
hbase是其他人建好的,如何知道rowkey
用java api 试试了
public class myclass {
static Configuration conf=HBaseConfiguration.create();
public static void main(String[] args) throws IOException {
HTable table = new HTable(conf,"表名称");
Scan scan = new Scan();
ResultScanner rs = table.getScanner(scan);
Result jg = rs.next();
KeyValue sz[ ] = jg.raw();
KeyValue hh=sz[0];
System.out.print(hh.getKeyString());
输出结果:x00x1Bx00x001425139209016230600645069x011x0Dx00x00x01KxD0xEAx93(x04用Get方法
Get get = new Get(Bytes.toBytes(上面的得结果));
返回空
上面结果的几种组合都试了试,比如去掉“x00x1Bx00x00”部分,或去掉“x011x0Dx00x00x01KxD0xEAx93(x04”部分,包括加,都不行
解决方案
参考how to list all row keys in an hbase table?
Configuration conf = HBaseConfiguration.create();
HTable table = new HTable(conf, tableName.getBytes());
System.out.println("scanning full table:");
ResultScanner scanner = table.getScanner(new Scan());
for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
byte[] key == rr.getRow();
}
时间: 2024-12-30 06:46:56