You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/01/16 06:07:27 UTC

[GitHub] [incubator-shardingsphere] beijing-penguin commented on a change in pull request #3988: Using multithreading make loadDefaultTables faster and remove repeat load tableMetaData

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:
users@infra.apache.org


With regards,
Apache Git Services