This is an automated email from the ASF dual-hosted git repository.

sunnianjun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new cc5730fa84b Refactor StorageUnitUtils (#28165)
cc5730fa84b is described below

commit cc5730fa84b738b76fce0c2f17a06283bd34e47b
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Aug 18 19:30:40 2023 +0800

    Refactor StorageUnitUtils (#28165)
    
    * Refactor usages of StorageUnitMetaData.dataSources
    
    * Refactor GlobalClockRule
    
    * Refactor StorageUnitUtils
---
 .../shardingsphere/proxy/backend/util/StorageUnitUtils.java  | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/StorageUnitUtils.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/StorageUnitUtils.java
index 26e07edb396..f915ad6f764 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/StorageUnitUtils.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/StorageUnitUtils.java
@@ -47,12 +47,13 @@ public final class StorageUnitUtils {
      */
     public static Map<String, Collection<String>> getInUsedStorageUnits(final 
RuleMetaData ruleMetaData, final int initialCapacity) {
         Map<String, Collection<String>> result = new 
LinkedHashMap<>(initialCapacity, 1F);
-        getFromDataSourceContainedRules(result, 
ruleMetaData.findRules(DataSourceContainedRule.class));
-        getFromDataNodeContainedRules(result, 
ruleMetaData.findRules(DataNodeContainedRule.class));
+        
result.putAll(getFromDataSourceContainedRules(ruleMetaData.findRules(DataSourceContainedRule.class)));
+        
result.putAll(getFromDataNodeContainedRules(ruleMetaData.findRules(DataNodeContainedRule.class)));
         return result;
     }
     
-    private static void getFromDataSourceContainedRules(final Map<String, 
Collection<String>> result, final Collection<DataSourceContainedRule> 
dataSourceContainedRules) {
+    private static Map<String, Collection<String>> 
getFromDataSourceContainedRules(final Collection<DataSourceContainedRule> 
dataSourceContainedRules) {
+        Map<String, Collection<String>> result = new LinkedHashMap<>();
         for (DataSourceContainedRule each : dataSourceContainedRules) {
             Collection<String> inUsedStorageUnits = 
getInUsedStorageUnitNames(each);
             if (inUsedStorageUnits.isEmpty()) {
@@ -64,9 +65,11 @@ public final class StorageUnitUtils {
                 result.put(storageUnit, rules);
             });
         }
+        return result;
     }
     
-    private static void getFromDataNodeContainedRules(final Map<String, 
Collection<String>> result, final Collection<DataNodeContainedRule> 
dataNodeContainedRules) {
+    private static Map<String, Collection<String>> 
getFromDataNodeContainedRules(final Collection<DataNodeContainedRule> 
dataNodeContainedRules) {
+        Map<String, Collection<String>> result = new LinkedHashMap<>();
         for (DataNodeContainedRule each : dataNodeContainedRules) {
             Collection<String> inUsedStorageUnits = 
getInUsedStorageUnitNames(each);
             if (inUsedStorageUnits.isEmpty()) {
@@ -78,6 +81,7 @@ public final class StorageUnitUtils {
                 result.put(storageUnit, rules);
             });
         }
+        return result;
     }
     
     private static Collection<String> getInUsedStorageUnitNames(final 
DataSourceContainedRule rule) {

Reply via email to