6.7 获取表中的所有数据
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("------ 分割线要长 ------");
}
}
}