<property>
<name>hbase.client.scanner.caching</name>
<value>10</value>
</property>
优化建议:使用批量get进行读取请求
public static List<String> qurryTableTestBatch(List<String> rowkeyList) throws IOException {
List<Get> getList = new ArrayList();
String tableName = "table_a";
Table table = connection.getTable( TableName.valueOf(tableName));// 获取表
for (String rowkey : rowkeyList){//把rowkey加到get里,再把get装到list中
Get get = new Get(Bytes.toBytes(rowkey));
getList.add(get);
}
Result[] results = table.get(getList);//重点在这,直接查getList<Get>
for (Result result : results){//对返回的结果集进行操作
for (Cell kv : result.rawCells()) {
String value = Bytes.toString(CellUtil.cloneValue(kv));
list.add(value);
}
}
return list;
}
Scan scan = new Scan();
scan.setStartRow(Bytes.toBytes(startRowKey));
scan.setStopRow(Bytes.toBytes(endRowKey));
//基于列族的过滤
Filter filter = new FamilyFilter(CompareFilter.CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("timeLen")));
scan.setFilter(filter);
scanner = table.getScanner(scan);
优化建议:离线批量读取请求设置禁用缓存,scan.setBlockCache(false)
asd
最新推荐文章于 2022-10-25 20:12:05 发布