optimization MetricsEsDAO multiGet (#5096)

This commit is contained in:
denis 2020-07-14 22:47:37 +08:00 committed by GitHub
parent c5972c2b7d
commit ce2469dbec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -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);
}

View File

@ -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);
}