totalo commented on a change in pull request #11028:
URL: https://github.com/apache/shardingsphere/pull/11028#discussion_r661950568
##########
File path:
shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java
##########
@@ -94,21 +96,21 @@ public StandardMetaDataContexts build() throws SQLException
{
Collection<RuleConfiguration> ruleConfigs =
schemaRuleConfigs.get(each);
DatabaseType databaseType =
DatabaseTypeRecognizer.getDatabaseType(dataSourceMap.values());
Collection<ShardingSphereRule> rules =
ShardingSphereRulesBuilder.buildSchemaRules(each, ruleConfigs, databaseType,
dataSourceMap);
- Map<Map<String, TableMetaData>, Map<String, TableMetaData>>
tableMetaDataMap = SchemaBuilder.build(new SchemaBuilderMaterials(databaseType,
dataSourceMap, rules, props));
+ Map<TableMetaData, TableMetaData> tableMetaDatas =
SchemaBuilder.build(new SchemaBuilderMaterials(databaseType, dataSourceMap,
rules, props));
ShardingSphereRuleMetaData ruleMetaData = new
ShardingSphereRuleMetaData(ruleConfigs, rules);
ShardingSphereResource resource = buildResource(databaseType,
dataSourceMap);
- ShardingSphereSchema actualSchema = new
ShardingSphereSchema(tableMetaDataMap.keySet().iterator().next());
+ ShardingSphereSchema actualSchema = new
ShardingSphereSchema(tableMetaDatas.keySet().stream().filter(Objects::nonNull).collect(Collectors.toMap(TableMetaData::getName,
v -> v)));
actualMetaDataMap.put(each, new ShardingSphereMetaData(each,
resource, ruleMetaData, actualSchema));
- metaDataMap.put(each, new ShardingSphereMetaData(each, resource,
ruleMetaData, buildSchema(tableMetaDataMap)));
+ metaDataMap.put(each, new ShardingSphereMetaData(each, resource,
ruleMetaData, buildSchema(tableMetaDatas)));
}
OptimizeContextFactory optimizeContextFactory = new
OptimizeContextFactory(actualMetaDataMap);
return new StandardMetaDataContexts(metaDataMap,
buildGlobalSchemaMetaData(metaDataMap), executorEngine, props,
optimizeContextFactory);
}
-
- private ShardingSphereSchema buildSchema(final Map<Map<String,
TableMetaData>, Map<String, TableMetaData>> tableMetaDataMap) {
- Map<String, TableMetaData> tables = new
HashMap<>(tableMetaDataMap.size(), 1);
- tables.putAll(tableMetaDataMap.keySet().iterator().next());
- tables.putAll(tableMetaDataMap.values().iterator().next());
+
+ private ShardingSphereSchema buildSchema(final Map<TableMetaData,
TableMetaData> tableMetaDatas) {
Review comment:
Yes, you are right, so there is no problem with understanding it. My
original understanding was to separate the two concepts. Based on this, I think
the current logic is a bit of a problem, my current logical table and physical
table are strictly separate. I'll revise my logic.
--
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]