strongduanmu commented on a change in pull request #11767:
URL: https://github.com/apache/shardingsphere/pull/11767#discussion_r690069926
##########
File path:
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/TableMetaDataBuilder.java
##########
@@ -79,7 +83,40 @@
}
return Optional.empty();
}
-
+
+ /**
+ * Load logic table metadata.
+ *
+ * @param materials schema builder materials
+ * @param executorService executorService
+ * @return table meta data collection
+ * @throws SQLException SQL exception
+ */
+ @SuppressWarnings("rawtypes")
+ public static Collection<TableMetaData> loadLogicTables(final
SchemaBuilderMaterials materials, final ExecutorService executorService) throws
SQLException {
+ Collection<TableMetaData> result = new LinkedList<>();
+ for (Entry<ShardingSphereRule, RuleBasedTableMetaDataBuilder> entry :
OrderedSPIRegistry.getRegisteredServices(RuleBasedTableMetaDataBuilder.class,
materials.getRules()).entrySet()) {
+ if (entry.getKey() instanceof TableContainedRule) {
+ loadTableContainedRuleTables(materials, executorService,
result, entry);
+ }
+ }
+ return result;
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private static void loadTableContainedRuleTables(final
SchemaBuilderMaterials materials, final ExecutorService executorService, final
Collection<TableMetaData> result,
+ final
Entry<ShardingSphereRule, RuleBasedTableMetaDataBuilder> ruleBuilderEntry)
throws SQLException {
+ TableContainedRule rule = (TableContainedRule)
ruleBuilderEntry.getKey();
+ RuleBasedTableMetaDataBuilder loader = ruleBuilderEntry.getValue();
+ Collection<String> needLoadTables = rule.getTables().stream()
+ .filter(each ->
!result.stream().map(TableMetaData::getName).collect(Collectors.toList()).contains(each)).collect(Collectors.toList());
Review comment:
@tuichenchuxin Please extract this logic to improve performance.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]