HBase:尝试从单行结果中获取键值

HBase:尝试从单行结果中获取键值,hbase,Hbase,这是我的密码: HTable someTable = new HTable(conf, "table"); Scan scan1 = new Scan(); scan1.setFilter(new FirstKeyOnlyFilter()); ResultScanner scanner = chkptTable.getScanner(scan1); Result firstKey = scanner.next(); 我需要在这里添加什么才能从单个返回行中仅获取键值 感谢您的帮助。在h

这是我的密码:

 HTable someTable = new HTable(conf, "table");
 Scan scan1 = new Scan();
 scan1.setFilter(new FirstKeyOnlyFilter());
 ResultScanner scanner = chkptTable.getScanner(scan1);
 Result firstKey = scanner.next();
我需要在这里添加什么才能从单个返回行中仅获取键值


感谢您的帮助。

在hbase-0.96之前,您可以使用以下代码获取密钥-
Configuration=HBaseConfiguration.create()
HTable table=新的HTable(conf,Bytes.toBytes(“testtable”)
扫描=新扫描()
scan.addFamily(Bytes.toBytes(“cf1”))
ResultScanner scanner=table.getScanner(扫描)
对于(结果:扫描仪){
System.out.println(Bytes.toString(result.getRow())
}
table.close()

但是,从-0.96版开始,建议使用
rawcell()
返回
Cell[]

必须先添加柱族


然后在您的
ResultScanner

上迭代,只需使用类Result的方法getRow()。 它将以字节[]的形式返回行键