【发布时间】:2021-11-20 15:31:27
【问题描述】:
我有一个 rest API,它使用 java 客户端从 HBase 检索大量行。
我已经实现了以下代码来将 hbase 行转换为数组数组。
List<List<String>> finalList = new ArrayList<List<String>>();
ResultScanner scanner = table.getScanner(scan);
List<String> rowSection = new ArrayList<String>();
try {
for (Result result = scanner.next(); (result != null); result = scanner.next()) {
rowSection.clear();
for (Cell cell : result.listCells()) {
String value = Bytes.toString(CellUtil.cloneValue(cell));
rowSection.add(value);
}
finalList.add(rowSection);
}
System.out.println("ARRAY SIZE: " + finalList.size());
} finally {
if (scanner != null) {
scanner.close();
}
}
我可以轻松地将其转换为对象数组,但我不确定这是否是转换 hbase 结果的正确方法。
有没有更高效的方式来做这件事,还是有一些自动的功能?
【问题讨论】:
标签: java arrays object hbase cloudera