6.7 获取表中的所有数据

/**
 * 获取表中的所有数据
 *
 * @param tableName
 */
private static void getData(String tableName) throws IOException {
    Table table = conn.getTable(TableName.valueOf(tableName));
    ResultScanner results = table.getScanner(new Scan());
    for (Result result : results) {
        byte[] row = result.getRow();
        Cell[] cells = result.rawCells();
        for (Cell cell : cells) {
            String family = Bytes.toString(CellUtil.cloneFamily(cell));
            String column = Bytes.toString(CellUtil.cloneQualifier(cell));
            String rowKey = Bytes.toString(CellUtil.cloneRow(cell));
            String value = Bytes.toString(CellUtil.cloneValue(cell));
            System.out.println("value = " + value);
            System.out.println("rowKey = " + rowKey);
            System.out.println("column = " + column);
            System.out.println("family = " + family);
            System.out.println("------ 分割线要长 ------");
        }
    }
}
Copyright © 尚硅谷大数据 2019 all right reserved,powered by Gitbook
该文件最后修订时间: 2018-11-20 18:14:19

results matching ""

    No results matching ""