diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/BaseController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/BaseController.java index c434398679..553a5b6eea 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/BaseController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/BaseController.java @@ -43,7 +43,7 @@ public class BaseController { * @return check result code */ public Map checkPageParams(int pageNo, int pageSize) { - Map result = new HashMap<>(2); + Map result = new HashMap<>(4); Status resultEnum = Status.SUCCESS; String msg = Status.SUCCESS.getMsg(); if (pageNo <= 0) { @@ -197,7 +197,7 @@ public class BaseController { result.setCode(Status.SUCCESS.getCode()); result.setMsg(Status.SUCCESS.getMsg()); - Map map = new HashMap<>(4); + Map map = new HashMap<>(8); map.put(Constants.TOTAL_LIST, totalList); map.put(Constants.CURRENT_PAGE, currentPage); map.put(Constants.TOTAL_PAGE, totalPage); 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 22c58640cc..dc67ddddce 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 @@ -69,6 +69,11 @@ public class CollectionUtils { return coll == null || coll.isEmpty(); } + /** + * The load factor used when none specified in constructor. + */ + static final float DEFAULT_LOAD_FACTOR = 0.75f; + /** * String to map * @@ -97,7 +102,8 @@ public class CollectionUtils { return emptyMap; } String[] strings = str.split(separator); - Map map = new HashMap<>(strings.length); + int initialCapacity = (int)(strings.length / DEFAULT_LOAD_FACTOR) + 1; + Map map = new HashMap<>(initialCapacity); for (int i = 0; i < strings.length; i++) { String[] strArray = strings[i].split("="); if (strArray.length != 2) { diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java index 69ca97a3d8..0dfebe3590 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java @@ -331,7 +331,7 @@ public class QuartzExecutors { * @return data map */ public static Map buildDataMap(int projectId, int scheduleId, Schedule schedule) { - Map dataMap = new HashMap<>(3); + Map dataMap = new HashMap<>(8); dataMap.put(PROJECT_ID, projectId); dataMap.put(SCHEDULE_ID, scheduleId); dataMap.put(SCHEDULE, JSONUtils.toJson(schedule));