Java 查询 HBase 数据深度解析

Java 查询 HBase 数据深度解析

一、Get:精准查询

HBase 的优势:按 RowKey 查


单行查询示例

Get get = new Get("001".getBytes());
Result result = table.get(get);

取具体列

byte[] value = result.getValue(
        Bytes.toBytes("info"),
        Bytes.toBytes("name")
);

System.out.println(Bytes.toString(value));

二、Scan:全表扫描(慎用)

Scan scan = new Scan();
ResultScanner scanner = table.getScanner(scan);

for (Result r : scanner) {
    System.out.println(Bytes.toString(r.getRow()));
}

Scan = 全 Region 扫描,性能很差

posted @ 2025-10-21 15:55  元始天尊123  阅读(5)  评论(0)    收藏  举报