Browse Source

[Improvement-8218][dolphinscheduler-api] QueryTaskInstanceListPaging API performance improvement (#8223)

3.0.0/version-upgrade
ouyangyewei 3 years ago committed by GitHub
parent
commit
294882f5d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
  2. 5
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java

5
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<Integer, User> 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());

5
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java

@ -78,9 +78,6 @@ public class CollectionUtils {
*/
public static <T extends Object> List<Map<String, Object>> getListByExclusion(List<T> originList, Set<String> exclusionSet) {
List<Map<String, Object>> 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<Object, Object> entry : beanMap.entrySet()) {
if (exclusionSet.contains(entry.getKey())) {
if (exclusionSet != null && exclusionSet.contains(entry.getKey())) {
continue;
}
instanceMap.put((String) entry.getKey(), entry.getValue());

Loading…
Cancel
Save