beijing-penguin commented on a change in pull request #3988: Using 
multithreading make loadDefaultTables faster and remove repeat load 
tableMetaData
URL: 
https://github.com/apache/incubator-shardingsphere/pull/3988#discussion_r367245008
 
 

 ##########
 File path: 
sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/sharding/execute/metadata/loader/ShardingTableMetaDataLoader.java
 ##########
 @@ -206,19 +207,46 @@ public TableMetas loadAll(final ShardingRule 
shardingRule) throws SQLException {
         return result;
     }
     
-    private Map<String, TableMetaData> loadDefaultTables(final ShardingRule 
shardingRule) throws SQLException {
+    private Map<String, TableMetaData> loadDefaultTables(final ShardingRule 
shardingRule, final Map<String, TableMetaData> result) throws SQLException {
         Optional<String> actualDefaultDataSourceName = 
shardingRule.findActualDefaultDataSourceName();
         if (!actualDefaultDataSourceName.isPresent()) {
             return Collections.emptyMap();
         }
         Collection<String> tableNames = 
loadAllTableNames(actualDefaultDataSourceName.get());
-        Map<String, TableMetaData> result = new HashMap<>(tableNames.size(), 
1);
-        for (String each : tableNames) {
-            result.put(each, load(each, shardingRule));
+        removeRepeatTable(tableNames, result);
 
 Review comment:
   > If there are two tables with the same name `t1` and different structures 
in ds0 and default ds seperately, do you think removeRepeatTable() could return 
correct result list?
   
   yes, load() methed  will be get out the same as tableMetaData by table 
name...loadShardingTables or loadDefaultTables execute load() method and only 
first parameter table name is different.
   
![image](https://user-images.githubusercontent.com/10703753/72498045-26afd300-3869-11ea-9d7e-4c6135c49a9d.png)
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to