You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/08/17 14:08:44 UTC
[GitHub] [dolphinscheduler] stalary commented on a diff in pull request #11522: [Improvement][TaskInstance] reduce database queries
stalary commented on code in PR #11522:
URL: https://github.com/apache/dolphinscheduler/pull/11522#discussion_r947980835
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java:
##########
@@ -1730,8 +1736,14 @@ public Map<String, Object> viewTree(User loginUser, long projectCode, long code,
// set treeViewDto instances
for (int i = limit - 1; i >= 0; i--) {
ProcessInstance processInstance = processInstanceList.get(i);
- TaskInstance taskInstance = taskInstanceMapper.queryByInstanceIdAndCode(processInstance.getId(),
- Long.parseLong(nodeCode));
+ TaskInstance taskInstance = null;
Review Comment:
```suggestion
TaskInstance taskInstance = taskInstances.stream().filter(instance -> instance.getTaskCode() == Long.parseLong(nodeCode) && instance.getProcessInstanceId() == processInstance.getId()).findFirst().orElse(null);
```
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java:
##########
@@ -780,24 +780,36 @@ public Map<String, Object> viewGantt(long projectCode, Integer processInstanceId
ganttDto.setTaskNames(nodeList);
List<Task> taskList = new ArrayList<>();
- for (String node : nodeList) {
- TaskInstance taskInstance =
- taskInstanceMapper.queryByInstanceIdAndCode(processInstanceId, Long.parseLong(node));
- if (taskInstance == null) {
- continue;
+ if (!nodeList.isEmpty()) {
+ List<Long> taskCodes = nodeList.stream().map(Long::parseLong).collect(Collectors.toList());
+ List<TaskInstance> taskInstances = taskInstanceMapper.queryByInstanceIdsAndCodes(
+ Collections.singletonList(processInstanceId), taskCodes
+ );
+ for (String node : nodeList) {
+ TaskInstance taskInstance = null;
+ for (TaskInstance instance : taskInstances) {
Review Comment:
Same as above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org