6.8 获取某一行数据

/**
 * 获取表中某一行的数据
 *
 * @param tableName
 * @param row
 */
private static void getRowData(String tableName, String row) throws IOException {
    Table table = conn.getTable(TableName.valueOf(tableName));

    Get get = new Get(Bytes.toBytes(row));
    Result result = table.get(get);
    List<Cell> cells = result.listCells();
    for (Cell cell : cells) {
        String family = Bytes.toString(CellUtil.cloneFamily(cell));
        String value = Bytes.toString(CellUtil.cloneValue(cell));
        String rowName = Bytes.toString(CellUtil.cloneRow(cell));
        String column = Bytes.toString(CellUtil.cloneQualifier(cell));
        System.out.println("column = " + column);
        System.out.println("rowName = " + rowName);
        System.out.println("value = " + value);
        System.out.println("family = " + family);


    }
}
Copyright © 尚硅谷大数据 2019 all right reserved,powered by Gitbook
该文件最后修订时间: 2018-11-20 18:14:19

results matching ""

    No results matching ""