From 294882f5d72598283438c8bdc4297d018f59e5a7 Mon Sep 17 00:00:00 2001 From: ouyangyewei Date: Wed, 9 Feb 2022 12:58:15 +0800 Subject: [PATCH] [Improvement-8218][dolphinscheduler-api] QueryTaskInstanceListPaging API performance improvement (#8223) --- .../api/service/impl/TaskInstanceServiceImpl.java | 5 +++-- .../dolphinscheduler/common/utils/CollectionUtils.java | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java index ab53c58878..e25cde6bc2 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java @@ -143,8 +143,9 @@ public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInst Map userMap = users.stream().collect(Collectors.toMap(User::getId, v -> v)); for (TaskInstance taskInstance : taskInstanceList) { taskInstance.setDuration(DateUtils.format2Duration(taskInstance.getStartTime(), taskInstance.getEndTime())); - if (userMap.containsKey(taskInstance.getExecutorId())) { - taskInstance.setExecutorName(userMap.get(taskInstance.getExecutorId()).getUserName()); + User user = userMap.get(taskInstance.getExecutorId()); + if (user != null) { + taskInstance.setExecutorName(user.getUserName()); } } pageInfo.setTotal((int) taskInstanceIPage.getTotal()); diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java index 295fb776f4..a48ed1f29d 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java @@ -78,9 +78,6 @@ public class CollectionUtils { */ public static List> getListByExclusion(List originList, Set exclusionSet) { List> instanceList = new ArrayList<>(); - if (exclusionSet == null) { - exclusionSet = new HashSet<>(); - } if (originList == null) { return instanceList; } @@ -89,7 +86,7 @@ public class CollectionUtils { BeanMap beanMap = new BeanMap(instance); instanceMap = new LinkedHashMap<>(16, 0.75f, true); for (Map.Entry entry : beanMap.entrySet()) { - if (exclusionSet.contains(entry.getKey())) { + if (exclusionSet != null && exclusionSet.contains(entry.getKey())) { continue; } instanceMap.put((String) entry.getKey(), entry.getValue());