未验证 提交 ce2469db 编写于 作者: D denis 提交者: GitHub

optimization MetricsEsDAO multiGet (#5096)

上级 c5972c2b
......@@ -44,8 +44,8 @@ public class MetricsEsDAO extends EsDAO implements IMetricsDAO {
public List<Metrics> multiGet(Model model, List<String> ids) throws IOException {
SearchResponse response = getClient().ids(model.getName(), ids.toArray(new String[0]));
List<Metrics> result = new ArrayList<>((int) response.getHits().totalHits);
for (int i = 0; i < response.getHits().totalHits; i++) {
List<Metrics> result = new ArrayList<>(response.getHits().getHits().length);
for (int i = 0; i < response.getHits().getHits().length; i++) {
Metrics source = storageBuilder.map2Data(response.getHits().getAt(i).getSourceAsMap());
result.add(source);
}
......
......@@ -39,8 +39,8 @@ public class MetricsEs7DAO extends MetricsEsDAO {
public List<Metrics> multiGet(Model model, List<String> ids) throws IOException {
SearchResponse response = getClient().ids(model.getName(), ids.toArray(new String[0]));
List<Metrics> result = new ArrayList<>((int) response.getHits().getTotalHits().value);
for (int i = 0; i < response.getHits().getTotalHits().value; i++) {
List<Metrics> result = new ArrayList<>(response.getHits().getHits().length);
for (int i = 0; i < response.getHits().getHits().length; i++) {
Metrics source = storageBuilder.map2Data(response.getHits().getAt(i).getSourceAsMap());
result.add(source);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册