这个代码你可以参考一下:
- public static void QueryAll(String tableName) {
- HTablePool pool = new HTablePool(configuration, 1000);
- HTable table = (HTable) pool.getTable(tableName);
- try {
- ResultScanner rs = table.getScanner(new Scan());
- for (Result r : rs) {
- System.out.println("获得到rowkey:" + new String(r.getRow()));
- for (KeyValue keyValue : r.raw()) {
- System.out.println("列:" + new String(keyValue.getFamily())
- + "====值:" + new String(keyValue.getValue()));
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
复制代码
该下面内容就可以
- ResultScanner rs = table.getScanner(new Scan());
- for (Result r : rs) {
- System.out.println("获得到rowkey:" + new String(r.getRow()));
- for (KeyValue keyValue : r.raw()) {
- System.out.println("列:" + new String(keyValue.getFamily())
- + "====值:" + new String(keyValue.getValue()));
- }
- }
复制代码
上面是通过ResultScanner对象,如同hbase的ResultScanner,然后在循环,这样就可以获取了
|