This is an automated email from the ASF dual-hosted git repository.
lidongdai pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 1f92b4c Optimize ParameterUtils.curingGlobalParams() execution
efficiency (#2090)
1f92b4c is described below
commit 1f92b4c4db3c2b96d767476bf77002d894de49c2
Author: dailidong <[email protected]>
AuthorDate: Thu Mar 5 23:21:10 2020 +0800
Optimize ParameterUtils.curingGlobalParams() execution efficiency (#2090)
* Optimize ParameterUtils.curingGlobalParams() execution efficiency
* Remove excess null check
---
.../common/utils/ParameterUtils.java | 36 ++++++++++------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
index 7f28883..9492b49 100644
---
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
+++
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java
@@ -119,10 +119,15 @@ public class ParameterUtils {
*/
public static String curingGlobalParams(Map<String,String> globalParamMap,
List<Property> globalParamList,
CommandType commandType, Date scheduleTime){
- Map<String, String> globalMap = new HashMap<>();
- if(globalParamMap!= null){
- globalMap.putAll(globalParamMap);
- }
+
+ if (globalParamList == null || globalParamList.isEmpty()) {
+ return null;
+ }
+
+ Map<String, String> globalMap = new HashMap<>();
+ if (globalParamMap!= null){
+ globalMap.putAll(globalParamMap);
+ }
Map<String,String> allParamMap = new HashMap<>();
//If it is a complement, a complement time needs to be passed in,
according to the task type
Map<String,String> timeParams = BusinessTimeUtils
@@ -132,9 +137,7 @@ public class ParameterUtils {
allParamMap.putAll(timeParams);
}
- if (globalMap != null) {
- allParamMap.putAll(globalMap);
- }
+ allParamMap.putAll(globalMap);
Set<Map.Entry<String, String>> entries = allParamMap.entrySet();
@@ -146,22 +149,15 @@ public class ParameterUtils {
resolveMap.put(entry.getKey(),str);
}
}
+ globalMap.putAll(resolveMap);
- if (globalMap != null){
- globalMap.putAll(resolveMap);
- }
-
- if (globalParamList != null && globalParamList.size() > 0){
-
- for (Property property : globalParamList){
- String val = globalMap.get(property.getProp());
- if (val != null){
- property.setValue(val);
- }
+ for (Property property : globalParamList){
+ String val = globalMap.get(property.getProp());
+ if (val != null){
+ property.setValue(val);
}
- return JSONObject.toJSONString(globalParamList);
}
- return null;
+ return JSONObject.toJSONString(globalParamList);
}