You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/07/14 14:47:53 UTC

[skywalking] branch master updated: optimization MetricsEsDAO multiGet (#5096)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new ce2469d  optimization MetricsEsDAO multiGet (#5096)
ce2469d is described below

commit ce2469dbecbc137c856b262dd8df4f78dc37f60f
Author: denis <am...@qq.com>
AuthorDate: Tue Jul 14 22:47:37 2020 +0800

    optimization MetricsEsDAO multiGet (#5096)
---
 .../oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java    | 4 ++--
 .../oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java
index 10b4f85..d78c960 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java
@@ -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);
         }
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java
index 6bf2836..bec72db 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/dao/MetricsEs7DAO.java
@@ -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);
         }