This is an automated email from the ASF dual-hosted git repository.
panjuan 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 bb7d089f43d Refactor TableMapperContainedRule (#30302)
bb7d089f43d is described below
commit bb7d089f43d76d6905650884de0f1a68c4cb5d60
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Feb 26 21:43:59 2024 +0800
Refactor TableMapperContainedRule (#30302)
---
.../broadcast/rule/BroadcastRule.java | 37 ++---------
.../broadcast/rule/BroadcastTableMapperRule.java | 30 +++++----
.../shardingsphere/encrypt/rule/EncryptRule.java | 33 +++-------
.../encrypt/rule/EncryptTableMapperRule.java | 31 ++++++----
.../encrypt/rule/EncryptRuleTest.java | 5 +-
.../query/EncryptCountResultRowBuilder.java | 2 +-
.../apache/shardingsphere/mask/rule/MaskRule.java | 30 ++-------
.../mask/rule/MaskTableMapperRule.java | 29 +++++----
.../handler/query/MaskCountResultRowBuilder.java | 2 +-
.../shardingsphere/sharding/rule/ShardingRule.java | 48 ++-------------
.../sharding/rule/ShardingTableMapperRule.java | 71 ++++++++++++++++++++++
.../common/IteratorStreamMergedResultTest.java | 4 +-
.../dql/orderby/OrderByStreamMergedResultTest.java | 4 +-
.../merge/dql/orderby/OrderByValueTest.java | 4 +-
.../dml/ShardingInsertStatementValidatorTest.java | 4 +-
.../sharding/rule/ShardingRuleTest.java | 2 +-
.../statement/dml/SelectStatementContext.java | 10 +--
.../select/pagination/PaginationContextTest.java | 4 +-
.../engine/ProjectionsContextEngineTest.java | 4 +-
.../statement/dml/SelectStatementContextTest.java | 8 +--
.../schema/builder/GenericSchemaBuilder.java | 7 ++-
.../TableMapperContainedRule.java} | 35 +++--------
.../TableMapperRule.java} | 8 +--
.../type/{ => table}/TableNamesMapper.java | 2 +-
.../database/ShardingSphereDatabaseTest.java | 4 +-
.../schema/builder/GenericSchemaBuilderTest.java | 4 +-
...e.java => TableMapperContainedFixtureRule.java} | 32 ++++------
.../rule/identifier/type/TableNamesMapperTest.java | 1 +
.../table/DropTableStatementSchemaRefresher.java | 4 +-
.../refresher/util/TableRefreshUtils.java | 4 +-
.../shardingsphere/single/rule/SingleRule.java | 38 +++---------
.../single/rule/SingleTableMapperRule.java | 30 +++++----
.../single/util/SingleTableLoadUtils.java | 17 +++---
.../datanode/SingleTableDataNodeLoaderTest.java | 6 +-
.../shardingsphere/single/rule/SingleRuleTest.java | 30 ++++-----
.../query/ShowUnloadedSingleTableExecutor.java | 2 +-
.../handler/query/SingleCountResultRowBuilder.java | 2 +-
.../handler/update/UnloadSingleTableExecutor.java | 2 +-
.../traffic/rule/TrafficRuleTest.java | 4 +-
.../context/ResourceMetaDataContextManager.java | 4 +-
.../NewStandaloneModeContextManager.java | 4 +-
.../standalone/StandaloneModeContextManager.java | 4 +-
42 files changed, 273 insertions(+), 333 deletions(-)
diff --git
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java
index ac2532aaf16..35454ee182e 100644
---
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java
+++
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastRule.java
@@ -24,8 +24,8 @@ import
org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.identifier.scope.DatabaseRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableNamesMapper;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperRule;
import javax.sql.DataSource;
import java.util.Collection;
@@ -42,7 +42,7 @@ import java.util.stream.Collectors;
* Broadcast rule.
*/
@Getter
-public final class BroadcastRule implements DatabaseRule,
DataNodeContainedRule, TableContainedRule {
+public final class BroadcastRule implements DatabaseRule,
DataNodeContainedRule, TableMapperContainedRule {
private final BroadcastRuleConfiguration configuration;
@@ -54,15 +54,16 @@ public final class BroadcastRule implements DatabaseRule,
DataNodeContainedRule,
private final Map<String, Collection<DataNode>> tableDataNodes;
- private final TableNamesMapper logicalTableMapper;
+ private final TableMapperRule tableMapperRule;
public BroadcastRule(final BroadcastRuleConfiguration config, final String
databaseName, final Map<String, DataSource> dataSources, final
Collection<ShardingSphereRule> builtRules) {
configuration = config;
this.databaseName = databaseName;
dataSourceNames = getAggregatedDataSourceNames(dataSources,
builtRules);
tables = createBroadcastTables(config.getTables());
- logicalTableMapper = createTableMapper();
tableDataNodes = createShardingTableDataNodes(dataSourceNames, tables);
+ tableMapperRule = new BroadcastTableMapperRule(tables);
+
}
private Collection<String> getAggregatedDataSourceNames(final Map<String,
DataSource> dataSources, final Collection<ShardingSphereRule> builtRules) {
@@ -97,12 +98,6 @@ public final class BroadcastRule implements DatabaseRule,
DataNodeContainedRule,
return result;
}
- private TableNamesMapper createTableMapper() {
- TableNamesMapper result = new TableNamesMapper();
- tables.forEach(result::put);
- return result;
- }
-
private Map<String, Collection<DataNode>>
createShardingTableDataNodes(final Collection<String> dataSourceNames, final
Collection<String> tables) {
Map<String, Collection<DataNode>> result = new
HashMap<>(tables.size(), 1F);
for (String each : tables) {
@@ -174,24 +169,4 @@ public final class BroadcastRule implements DatabaseRule,
DataNodeContainedRule,
public boolean isAllBroadcastTables(final Collection<String>
logicTableNames) {
return !logicTableNames.isEmpty() &&
tables.containsAll(logicTableNames);
}
-
- @Override
- public TableNamesMapper getLogicTableMapper() {
- return logicalTableMapper;
- }
-
- @Override
- public TableNamesMapper getActualTableMapper() {
- return new TableNamesMapper();
- }
-
- @Override
- public TableNamesMapper getDistributedTableMapper() {
- return getLogicTableMapper();
- }
-
- @Override
- public TableNamesMapper getEnhancedTableMapper() {
- return new TableNamesMapper();
- }
}
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastTableMapperRule.java
similarity index 64%
copy from
infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
copy to
features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastTableMapperRule.java
index 91251a632ed..56234af3a00 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
+++
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/BroadcastTableMapperRule.java
@@ -15,19 +15,28 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.metadata.database.schema.fixture.rule;
+package org.apache.shardingsphere.broadcast.rule;
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableNamesMapper;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableNamesMapper;
-import static org.mockito.Mockito.mock;
+import java.util.Collection;
-public final class TableContainedFixtureRule implements TableContainedRule {
+/**
+ * Broadcast table mapper rule.
+ */
+public final class BroadcastTableMapperRule implements TableMapperRule {
+
+ private final TableNamesMapper logicalTableMapper;
+
+ public BroadcastTableMapperRule(final Collection<String> tables) {
+ logicalTableMapper = new TableNamesMapper();
+ tables.forEach(logicalTableMapper::put);
+ }
@Override
public TableNamesMapper getLogicTableMapper() {
- return new TableNamesMapper();
+ return logicalTableMapper;
}
@Override
@@ -37,16 +46,11 @@ public final class TableContainedFixtureRule implements
TableContainedRule {
@Override
public TableNamesMapper getDistributedTableMapper() {
- return new TableNamesMapper();
+ return getLogicTableMapper();
}
@Override
public TableNamesMapper getEnhancedTableMapper() {
return new TableNamesMapper();
}
-
- @Override
- public RuleConfiguration getConfiguration() {
- return mock(RuleConfiguration.class);
- }
}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
index 024633f28a2..050021c5cad 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
@@ -27,8 +27,7 @@ import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.rule.identifier.scope.DatabaseRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableNamesMapper;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import java.util.LinkedHashMap;
@@ -39,26 +38,28 @@ import java.util.Optional;
/**
* Encrypt rule.
*/
-public final class EncryptRule implements DatabaseRule, TableContainedRule {
+public final class EncryptRule implements DatabaseRule,
TableMapperContainedRule {
private final String databaseName;
@Getter
private final EncryptRuleConfiguration configuration;
- private final Map<String, EncryptTable> tables = new LinkedHashMap<>();
+ private final Map<String, EncryptTable> tables;
- private final TableNamesMapper tableNamesMapper = new TableNamesMapper();
+ @Getter
+ private final EncryptTableMapperRule tableMapperRule;
public EncryptRule(final String databaseName, final
EncryptRuleConfiguration ruleConfig) {
this.databaseName = databaseName;
configuration = ruleConfig;
+ tables = new LinkedHashMap<>();
Map<String, EncryptAlgorithm> encryptors =
createEncryptors(ruleConfig);
for (EncryptTableRuleConfiguration each : ruleConfig.getTables()) {
each.getColumns().forEach(columnRuleConfig ->
checkEncryptorType(columnRuleConfig, encryptors));
tables.put(each.getName().toLowerCase(), new EncryptTable(each,
encryptors));
- tableNamesMapper.put(each.getName());
}
+ tableMapperRule = new EncryptTableMapperRule(ruleConfig.getTables());
}
private Map<String, EncryptAlgorithm> createEncryptors(final
EncryptRuleConfiguration ruleConfig) {
@@ -102,24 +103,4 @@ public final class EncryptRule implements DatabaseRule,
TableContainedRule {
ShardingSpherePreconditions.checkState(encryptTable.isPresent(), () ->
new EncryptTableNotFoundException(tableName));
return encryptTable.get();
}
-
- @Override
- public TableNamesMapper getLogicTableMapper() {
- return tableNamesMapper;
- }
-
- @Override
- public TableNamesMapper getActualTableMapper() {
- return new TableNamesMapper();
- }
-
- @Override
- public TableNamesMapper getDistributedTableMapper() {
- return new TableNamesMapper();
- }
-
- @Override
- public TableNamesMapper getEnhancedTableMapper() {
- return getLogicTableMapper();
- }
}
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTableMapperRule.java
similarity index 59%
copy from
infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
copy to
features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTableMapperRule.java
index 91251a632ed..7a6f0e9fd96 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTableMapperRule.java
@@ -15,19 +15,29 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.metadata.database.schema.fixture.rule;
+package org.apache.shardingsphere.encrypt.rule;
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableNamesMapper;
+import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableNamesMapper;
-import static org.mockito.Mockito.mock;
+import java.util.Collection;
-public final class TableContainedFixtureRule implements TableContainedRule {
+/**
+ * Encrypt table mapper rule.
+ */
+public final class EncryptTableMapperRule implements TableMapperRule {
+
+ private final TableNamesMapper logicalTableMapper;
+
+ public EncryptTableMapperRule(final
Collection<EncryptTableRuleConfiguration> tables) {
+ logicalTableMapper = new TableNamesMapper();
+
tables.stream().map(EncryptTableRuleConfiguration::getName).forEach(logicalTableMapper::put);
+ }
@Override
public TableNamesMapper getLogicTableMapper() {
- return new TableNamesMapper();
+ return logicalTableMapper;
}
@Override
@@ -42,11 +52,6 @@ public final class TableContainedFixtureRule implements
TableContainedRule {
@Override
public TableNamesMapper getEnhancedTableMapper() {
- return new TableNamesMapper();
- }
-
- @Override
- public RuleConfiguration getConfiguration() {
- return mock(RuleConfiguration.class);
+ return getLogicTableMapper();
}
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java
index 9a1e11e831c..d0512c3cd72 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptRuleTest.java
@@ -63,12 +63,13 @@ class EncryptRuleTest {
@Test
void assertGetTables() {
- assertThat(new LinkedList<>(new EncryptRule("foo_db",
createEncryptRuleConfiguration()).getLogicTableMapper().getTableNames()),
is(Collections.singletonList("t_encrypt")));
+ assertThat(new LinkedList<>(new EncryptRule("foo_db",
createEncryptRuleConfiguration()).getTableMapperRule().getLogicTableMapper().getTableNames()),
+ is(Collections.singletonList("t_encrypt")));
}
@Test
void assertGetTableWithLowercase() {
- assertThat(new LinkedList<>(new EncryptRule("foo_db",
createEncryptRuleConfigurationWithUpperCaseLogicTable()).getLogicTableMapper().getTableNames()),
+ assertThat(new LinkedList<>(new EncryptRule("foo_db",
createEncryptRuleConfigurationWithUpperCaseLogicTable()).getTableMapperRule().getLogicTableMapper().getTableNames()),
is(Collections.singletonList("T_ENCRYPT")));
}
diff --git
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptCountResultRowBuilder.java
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptCountResultRowBuilder.java
index 91776b7c216..595dd478072 100644
---
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptCountResultRowBuilder.java
+++
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/EncryptCountResultRowBuilder.java
@@ -31,7 +31,7 @@ public final class EncryptCountResultRowBuilder implements
CountResultRowBuilder
@Override
public Collection<LocalDataQueryResultRow> generateRows(final EncryptRule
rule, final String databaseName) {
- return Collections.singleton(new LocalDataQueryResultRow("encrypt",
databaseName, rule.getLogicTableMapper().getTableNames().size()));
+ return Collections.singleton(new LocalDataQueryResultRow("encrypt",
databaseName,
rule.getTableMapperRule().getLogicTableMapper().getTableNames().size()));
}
@Override
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java
index 2ace6855fdb..e93baec68c1 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskRule.java
@@ -19,8 +19,7 @@ package org.apache.shardingsphere.mask.rule;
import lombok.Getter;
import org.apache.shardingsphere.infra.rule.identifier.scope.DatabaseRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableNamesMapper;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
@@ -33,7 +32,7 @@ import java.util.Optional;
* Mask rule.
*/
@SuppressWarnings("rawtypes")
-public final class MaskRule implements DatabaseRule, TableContainedRule {
+public final class MaskRule implements DatabaseRule, TableMapperContainedRule {
@Getter
private final MaskRuleConfiguration configuration;
@@ -42,13 +41,14 @@ public final class MaskRule implements DatabaseRule,
TableContainedRule {
private final Map<String, MaskTable> tables = new LinkedHashMap<>();
- private final TableNamesMapper tableNamesMapper = new TableNamesMapper();
+ @Getter
+ private final MaskTableMapperRule tableMapperRule;
public MaskRule(final MaskRuleConfiguration ruleConfig) {
configuration = ruleConfig;
ruleConfig.getMaskAlgorithms().forEach((key, value) ->
maskAlgorithms.put(key, TypedSPILoader.getService(MaskAlgorithm.class,
value.getType(), value.getProps())));
ruleConfig.getTables().forEach(each ->
tables.put(each.getName().toLowerCase(), new MaskTable(each)));
- ruleConfig.getTables().forEach(each ->
tableNamesMapper.put(each.getName()));
+ tableMapperRule = new MaskTableMapperRule(ruleConfig.getTables());
}
/**
@@ -62,24 +62,4 @@ public final class MaskRule implements DatabaseRule,
TableContainedRule {
String lowerCaseLogicTable = logicTable.toLowerCase();
return tables.containsKey(lowerCaseLogicTable) ?
tables.get(lowerCaseLogicTable).findMaskAlgorithmName(logicColumn).map(maskAlgorithms::get)
: Optional.empty();
}
-
- @Override
- public TableNamesMapper getLogicTableMapper() {
- return tableNamesMapper;
- }
-
- @Override
- public TableNamesMapper getActualTableMapper() {
- return new TableNamesMapper();
- }
-
- @Override
- public TableNamesMapper getDistributedTableMapper() {
- return new TableNamesMapper();
- }
-
- @Override
- public TableNamesMapper getEnhancedTableMapper() {
- return new TableNamesMapper();
- }
}
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskTableMapperRule.java
similarity index 62%
copy from
infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
copy to
features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskTableMapperRule.java
index 91251a632ed..143733dc69a 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskTableMapperRule.java
@@ -15,19 +15,29 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.metadata.database.schema.fixture.rule;
+package org.apache.shardingsphere.mask.rule;
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableNamesMapper;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableNamesMapper;
+import
org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
-import static org.mockito.Mockito.mock;
+import java.util.Collection;
-public final class TableContainedFixtureRule implements TableContainedRule {
+/**
+ * Mask table mapper rule.
+ */
+public final class MaskTableMapperRule implements TableMapperRule {
+
+ private final TableNamesMapper logicalTableMapper;
+
+ public MaskTableMapperRule(final Collection<MaskTableRuleConfiguration>
tables) {
+ logicalTableMapper = new TableNamesMapper();
+
tables.stream().map(MaskTableRuleConfiguration::getName).forEach(logicalTableMapper::put);
+ }
@Override
public TableNamesMapper getLogicTableMapper() {
- return new TableNamesMapper();
+ return logicalTableMapper;
}
@Override
@@ -44,9 +54,4 @@ public final class TableContainedFixtureRule implements
TableContainedRule {
public TableNamesMapper getEnhancedTableMapper() {
return new TableNamesMapper();
}
-
- @Override
- public RuleConfiguration getConfiguration() {
- return mock(RuleConfiguration.class);
- }
}
diff --git
a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/MaskCountResultRowBuilder.java
b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/MaskCountResultRowBuilder.java
index a34a1524572..3c6f331f00f 100644
---
a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/MaskCountResultRowBuilder.java
+++
b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/MaskCountResultRowBuilder.java
@@ -31,7 +31,7 @@ public final class MaskCountResultRowBuilder implements
CountResultRowBuilder<Ma
@Override
public Collection<LocalDataQueryResultRow> generateRows(final MaskRule
rule, final String databaseName) {
- return Collections.singleton(new LocalDataQueryResultRow("mask",
databaseName, rule.getLogicTableMapper().getTableNames().size()));
+ return Collections.singleton(new LocalDataQueryResultRow("mask",
databaseName,
rule.getTableMapperRule().getLogicTableMapper().getTableNames().size()));
}
@Override
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
index 3252e4bb54f..a536b7a2a86 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
@@ -36,8 +36,7 @@ import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.rule.identifier.scope.DatabaseRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableNamesMapper;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -86,7 +85,7 @@ import java.util.stream.Collectors;
* Sharding rule.
*/
@Getter
-public final class ShardingRule implements DatabaseRule,
DataNodeContainedRule, TableContainedRule {
+public final class ShardingRule implements DatabaseRule,
DataNodeContainedRule, TableMapperContainedRule {
private static final String ALGORITHM_EXPRESSION_KEY =
"algorithm-expression";
@@ -118,9 +117,7 @@ public final class ShardingRule implements DatabaseRule,
DataNodeContainedRule,
private final ShardingCache shardingCache;
- private final TableNamesMapper logicalTableMapper;
-
- private final TableNamesMapper actualTableMapper;
+ private final ShardingTableMapperRule tableMapperRule;
public ShardingRule(final ShardingRuleConfiguration ruleConfig, final
Map<String, DataSource> dataSources, final InstanceContext instanceContext) {
configuration = ruleConfig;
@@ -148,8 +145,7 @@ public final class ShardingRule implements DatabaseRule,
DataNodeContainedRule,
((InstanceContextAware)
defaultKeyGenerateAlgorithm).setInstanceContext(instanceContext);
}
shardingCache = null == ruleConfig.getShardingCache() ? null : new
ShardingCache(ruleConfig.getShardingCache(), this);
- logicalTableMapper = createLogicalTableMapper();
- actualTableMapper = createActualTableMapper();
+ tableMapperRule = new ShardingTableMapperRule(shardingTables);
}
private void validateUniqueActualDataNodesInTableRules() {
@@ -172,22 +168,6 @@ public final class ShardingRule implements DatabaseRule,
DataNodeContainedRule,
return null == ruleConfig.getDefaultTableShardingStrategy() ? new
NoneShardingStrategyConfiguration() :
ruleConfig.getDefaultTableShardingStrategy();
}
- private TableNamesMapper createLogicalTableMapper() {
- TableNamesMapper result = new TableNamesMapper();
- shardingTables.values().forEach(each ->
result.put(each.getLogicTable()));
- return result;
- }
-
- private TableNamesMapper createActualTableMapper() {
- TableNamesMapper result = new TableNamesMapper();
- for (ShardingTable each : shardingTables.values()) {
- for (DataNode dataNode : each.getActualDataNodes()) {
- result.put(dataNode.getTableName());
- }
- }
- return result;
- }
-
private Map<String, Collection<DataNode>>
createShardingTableDataNodes(final Map<String, ShardingTable> shardingTables) {
Map<String, Collection<DataNode>> result = new
CaseInsensitiveMap<>(shardingTables.size(), 1F);
for (ShardingTable each : shardingTables.values()) {
@@ -344,26 +324,6 @@ public final class ShardingRule implements DatabaseRule,
DataNodeContainedRule,
return null == shardingColumn ? "" : shardingColumn;
}
- @Override
- public TableNamesMapper getLogicTableMapper() {
- return logicalTableMapper;
- }
-
- @Override
- public TableNamesMapper getActualTableMapper() {
- return actualTableMapper;
- }
-
- @Override
- public TableNamesMapper getDistributedTableMapper() {
- return getLogicTableMapper();
- }
-
- @Override
- public TableNamesMapper getEnhancedTableMapper() {
- return getLogicTableMapper();
- }
-
/**
* Get database sharding strategy configuration.
*
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingTableMapperRule.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingTableMapperRule.java
new file mode 100644
index 00000000000..91ba970de60
--- /dev/null
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingTableMapperRule.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sharding.rule;
+
+import org.apache.shardingsphere.infra.datanode.DataNode;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableNamesMapper;
+
+import java.util.Map;
+
+/**
+ * Sharding table mapper rule.
+ */
+public final class ShardingTableMapperRule implements TableMapperRule {
+
+ private final TableNamesMapper logicalTableMapper;
+
+ private final TableNamesMapper actualTableMapper;
+
+ public ShardingTableMapperRule(final Map<String, ShardingTable>
shardingTables) {
+ logicalTableMapper = createLogicalTableMapper(shardingTables);
+ actualTableMapper = createActualTableMapper(shardingTables);
+ }
+
+ private TableNamesMapper createLogicalTableMapper(final Map<String,
ShardingTable> shardingTables) {
+ TableNamesMapper result = new TableNamesMapper();
+ shardingTables.values().forEach(each ->
result.put(each.getLogicTable()));
+ return result;
+ }
+
+ private TableNamesMapper createActualTableMapper(final Map<String,
ShardingTable> shardingTables) {
+ TableNamesMapper result = new TableNamesMapper();
+ shardingTables.values().stream().flatMap(each ->
each.getActualDataNodes().stream()).map(DataNode::getTableName).forEach(result::put);
+ return result;
+ }
+
+ @Override
+ public TableNamesMapper getLogicTableMapper() {
+ return logicalTableMapper;
+ }
+
+ @Override
+ public TableNamesMapper getActualTableMapper() {
+ return actualTableMapper;
+ }
+
+ @Override
+ public TableNamesMapper getDistributedTableMapper() {
+ return getLogicTableMapper();
+ }
+
+ @Override
+ public TableNamesMapper getEnhancedTableMapper() {
+ return getLogicTableMapper();
+ }
+}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/common/IteratorStreamMergedResultTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/common/IteratorStreamMergedResultTest.java
index b8ae7900ece..efebd136867 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/common/IteratorStreamMergedResultTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/common/IteratorStreamMergedResultTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.merge.common;
import
org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.infra.session.connection.ConnectionContext;
import org.apache.shardingsphere.infra.database.core.DefaultDatabase;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
@@ -67,7 +67,7 @@ class IteratorStreamMergedResultTest {
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(result.getRuleMetaData().findRules(TableContainedRule.class)).thenReturn(Collections.emptyList());
+
when(result.getRuleMetaData().findRules(TableMapperContainedRule.class)).thenReturn(Collections.emptyList());
return result;
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java
index ca0b10f98f9..b35c9e9737b 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByStreamMergedResultTest.java
@@ -32,7 +32,7 @@ import
org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.infra.session.connection.ConnectionContext;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger;
@@ -82,7 +82,7 @@ class OrderByStreamMergedResultTest {
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(result.getRuleMetaData().findRules(TableContainedRule.class)).thenReturn(Collections.emptyList());
+
when(result.getRuleMetaData().findRules(TableMapperContainedRule.class)).thenReturn(Collections.emptyList());
return result;
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java
index bf92bc7186f..4c526c8d937 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java
@@ -28,7 +28,7 @@ import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaDa
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import
org.apache.shardingsphere.infra.database.core.metadata.database.enums.NullsOrderType;
import org.apache.shardingsphere.sql.parser.sql.common.enums.OrderDirection;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
@@ -117,7 +117,7 @@ class OrderByValueTest {
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(result.getRuleMetaData().findRules(TableContainedRule.class)).thenReturn(Collections.emptyList());
+
when(result.getRuleMetaData().findRules(TableMapperContainedRule.class)).thenReturn(Collections.emptyList());
return result;
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
index 75f4f91459d..213931828e2 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
@@ -33,7 +33,7 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import org.apache.shardingsphere.infra.route.context.RouteUnit;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
import
org.apache.shardingsphere.sharding.exception.algorithm.sharding.DuplicateInsertDataRecordException;
@@ -101,7 +101,7 @@ class ShardingInsertStatementValidatorTest {
Collection<String> tableNames =
sqlStatementContext.getTablesContext().getTableNames();
when(shardingRule.isAllShardingTables(tableNames)).thenReturn(false);
when(shardingRule.containsShardingTable(tableNames)).thenReturn(true);
-
when(database.getRuleMetaData().findRules(TableContainedRule.class)).thenReturn(Collections.emptyList());
+
when(database.getRuleMetaData().findRules(TableMapperContainedRule.class)).thenReturn(Collections.emptyList());
assertThrows(DMLWithMultipleShardingTablesException.class, () -> new
ShardingInsertStatementValidator(shardingConditions).preValidate(shardingRule,
sqlStatementContext, Collections.emptyList(), database,
mock(ConfigurationProperties.class)));
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index bfff17bbdb2..c6e21ab543d 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -458,7 +458,7 @@ class ShardingRuleTest {
@Test
void assertGetTables() {
- assertThat(new
LinkedList<>(createMaximumShardingRule().getLogicTableMapper().getTableNames()),
is(Arrays.asList("LOGIC_TABLE", "SUB_LOGIC_TABLE")));
+ assertThat(new
LinkedList<>(createMaximumShardingRule().getTableMapperRule().getLogicTableMapper().getTableNames()),
is(Arrays.asList("LOGIC_TABLE", "SUB_LOGIC_TABLE")));
}
@Test
diff --git
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContext.java
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContext.java
index b06a78ad1e1..b6703499d67 100644
---
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContext.java
+++
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContext.java
@@ -45,7 +45,7 @@ import
org.apache.shardingsphere.infra.exception.dialect.exception.syntax.databa
import
org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.UnknownDatabaseException;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import
org.apache.shardingsphere.sql.parser.sql.common.enums.ParameterMarkerType;
import org.apache.shardingsphere.sql.parser.sql.common.enums.SubqueryType;
import
org.apache.shardingsphere.sql.parser.sql.common.extractor.TableExtractor;
@@ -129,9 +129,9 @@ public final class SelectStatementContext extends
CommonSQLStatementContext impl
}
private boolean isContainsEnhancedTable(final ShardingSphereMetaData
metaData, final String databaseName, final Collection<String> tableNames) {
- for (TableContainedRule each : getTableContainedRules(metaData,
databaseName)) {
+ for (TableMapperContainedRule each : getTableContainedRules(metaData,
databaseName)) {
for (String tableName : tableNames) {
- if (each.getEnhancedTableMapper().contains(tableName)) {
+ if
(each.getTableMapperRule().getEnhancedTableMapper().contains(tableName)) {
return true;
}
}
@@ -139,14 +139,14 @@ public final class SelectStatementContext extends
CommonSQLStatementContext impl
return false;
}
- private Collection<TableContainedRule> getTableContainedRules(final
ShardingSphereMetaData metaData, final String databaseName) {
+ private Collection<TableMapperContainedRule> getTableContainedRules(final
ShardingSphereMetaData metaData, final String databaseName) {
if (null == databaseName) {
ShardingSpherePreconditions.checkState(tablesContext.getSimpleTableSegments().isEmpty(),
NoDatabaseSelectedException::new);
return Collections.emptyList();
}
ShardingSphereDatabase database = metaData.getDatabase(databaseName);
ShardingSpherePreconditions.checkNotNull(database, () -> new
UnknownDatabaseException(databaseName));
- return database.getRuleMetaData().findRules(TableContainedRule.class);
+ return
database.getRuleMetaData().findRules(TableMapperContainedRule.class);
}
private Map<Integer, SelectStatementContext> createSubqueryContexts(final
ShardingSphereMetaData metaData, final List<Object> params, final String
defaultDatabaseName) {
diff --git
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/PaginationContextTest.java
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/PaginationContextTest.java
index 59002817f38..6973d2225b5 100644
---
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/PaginationContextTest.java
+++
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/PaginationContextTest.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.sql.parser.sql.common.enums.OrderDirection;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionsSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.GroupBySegment;
@@ -178,7 +178,7 @@ class PaginationContextTest {
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(result.getRuleMetaData().findRules(TableContainedRule.class)).thenReturn(Collections.emptyList());
+
when(result.getRuleMetaData().findRules(TableMapperContainedRule.class)).thenReturn(Collections.emptyList());
return result;
}
diff --git
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionsContextEngineTest.java
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionsContextEngineTest.java
index a96365d3dbb..643d1f5bc5c 100644
---
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionsContextEngineTest.java
+++
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionsContextEngineTest.java
@@ -29,7 +29,7 @@ import
org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.sql.parser.sql.common.enums.OrderDirection;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.subquery.SubquerySegment;
@@ -233,7 +233,7 @@ class ProjectionsContextEngineTest {
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(result.getRuleMetaData().findRules(TableContainedRule.class)).thenReturn(Collections.emptyList());
+
when(result.getRuleMetaData().findRules(TableMapperContainedRule.class)).thenReturn(Collections.emptyList());
return result;
}
diff --git
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContextTest.java
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContextTest.java
index 5139667dd35..552ee5702f2 100644
---
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContextTest.java
+++
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContextTest.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.sql.parser.sql.common.enums.AggregationType;
import org.apache.shardingsphere.sql.parser.sql.common.enums.OrderDirection;
import
org.apache.shardingsphere.sql.parser.sql.common.enums.ParameterMarkerType;
@@ -120,9 +120,9 @@ class SelectStatementContextTest {
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
- TableContainedRule tableContainedRule = mock(TableContainedRule.class,
RETURNS_DEEP_STUBS);
-
when(tableContainedRule.getEnhancedTableMapper().contains("t_order")).thenReturn(true);
-
when(result.getRuleMetaData().findRules(TableContainedRule.class)).thenReturn(Collections.singletonList(tableContainedRule));
+ TableMapperContainedRule tableContainedRule =
mock(TableMapperContainedRule.class, RETURNS_DEEP_STUBS);
+
when(tableContainedRule.getTableMapperRule().getEnhancedTableMapper().contains("t_order")).thenReturn(true);
+
when(result.getRuleMetaData().findRules(TableMapperContainedRule.class)).thenReturn(Collections.singletonList(tableContainedRule));
return result;
}
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/GenericSchemaBuilder.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/GenericSchemaBuilder.java
index d6b94bb29ea..6d259f53e94 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/GenericSchemaBuilder.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/GenericSchemaBuilder.java
@@ -37,7 +37,7 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
import
org.apache.shardingsphere.infra.metadata.database.schema.reviser.MetaDataReviseEngine;
import
org.apache.shardingsphere.infra.metadata.database.schema.util.SchemaMetaDataUtils;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import java.sql.SQLException;
import java.util.Collection;
@@ -84,7 +84,8 @@ public final class GenericSchemaBuilder {
}
private static Collection<String> getAllTableNames(final
Collection<ShardingSphereRule> rules) {
- return
rules.stream().filter(TableContainedRule.class::isInstance).flatMap(each ->
((TableContainedRule)
each).getLogicTableMapper().getTableNames().stream()).collect(Collectors.toSet());
+ return
rules.stream().filter(TableMapperContainedRule.class::isInstance)
+ .flatMap(each -> ((TableMapperContainedRule)
each).getTableMapperRule().getLogicTableMapper().getTableNames().stream()).collect(Collectors.toSet());
}
private static Map<String, SchemaMetaData> loadSchemas(final
Collection<String> tableNames, final GenericSchemaBuilderMaterial material)
throws SQLException {
@@ -110,7 +111,7 @@ public final class GenericSchemaBuilder {
private static Map<String, ShardingSphereSchema> revise(final Map<String,
SchemaMetaData> schemaMetaDataMap, final GenericSchemaBuilderMaterial material)
{
Map<String, SchemaMetaData> result = new
LinkedHashMap<>(schemaMetaDataMap);
- result.putAll(new
MetaDataReviseEngine(material.getRules().stream().filter(TableContainedRule.class::isInstance).collect(Collectors.toList())).revise(result,
material));
+ result.putAll(new
MetaDataReviseEngine(material.getRules().stream().filter(TableMapperContainedRule.class::isInstance).collect(Collectors.toList())).revise(result,
material));
return convertToSchemaMap(result, material);
}
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/TableContainedRule.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/table/TableMapperContainedRule.java
similarity index 55%
copy from
infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/TableContainedRule.java
copy to
infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/table/TableMapperContainedRule.java
index 2e9284ef111..d174689d872 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/TableContainedRule.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/table/TableMapperContainedRule.java
@@ -15,40 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.rule.identifier.type;
+package org.apache.shardingsphere.infra.rule.identifier.type.table;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
/**
- * ShardingSphere rule which contains table.
+ * Table mapper contained rule.
*/
-public interface TableContainedRule extends ShardingSphereRule {
+public interface TableMapperContainedRule extends ShardingSphereRule {
/**
- * Get logic table mapper.
- *
- * @return logic table mapper
+ * Get table mapper rule.
+ *
+ * @return table mapper rule
*/
- TableNamesMapper getLogicTableMapper();
-
- /**
- * Get actual table mapper.
- *
- * @return actual table mapper
- */
- TableNamesMapper getActualTableMapper();
-
- /**
- * Get distributed table mapper.
- *
- * @return distributed table mapper
- */
- TableNamesMapper getDistributedTableMapper();
-
- /**
- * Get enhanced table mapper.
- *
- * @return enhanced table mapper
- */
- TableNamesMapper getEnhancedTableMapper();
+ TableMapperRule getTableMapperRule();
}
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/TableContainedRule.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/table/TableMapperRule.java
similarity index 85%
rename from
infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/TableContainedRule.java
rename to
infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/table/TableMapperRule.java
index 2e9284ef111..0426eb198be 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/TableContainedRule.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/table/TableMapperRule.java
@@ -15,14 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.rule.identifier.type;
-
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+package org.apache.shardingsphere.infra.rule.identifier.type.table;
/**
- * ShardingSphere rule which contains table.
+ * Table mapper rule.
*/
-public interface TableContainedRule extends ShardingSphereRule {
+public interface TableMapperRule {
/**
* Get logic table mapper.
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/TableNamesMapper.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/table/TableNamesMapper.java
similarity index 96%
rename from
infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/TableNamesMapper.java
rename to
infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/table/TableNamesMapper.java
index 8e368505b91..dbf4c943d9f 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/TableNamesMapper.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/table/TableNamesMapper.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.rule.identifier.type;
+package org.apache.shardingsphere.infra.rule.identifier.type.table;
import com.cedarsoftware.util.CaseInsensitiveMap;
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabaseTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabaseTest.java
index fa3de5059d2..324e0dfecd7 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabaseTest.java
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabaseTest.java
@@ -27,7 +27,7 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.MutableDataNodeRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
import org.apache.shardingsphere.test.mock.AutoMockExtension;
@@ -152,7 +152,7 @@ class ShardingSphereDatabaseTest {
Collection<ShardingSphereRule> rules = new LinkedList<>();
rules.add(mock(MutableDataNodeRule.class, RETURNS_DEEP_STUBS));
rules.add(mock(DataSourceContainedRule.class, RETURNS_DEEP_STUBS));
- rules.add(mock(TableContainedRule.class, RETURNS_DEEP_STUBS));
+ rules.add(mock(TableMapperContainedRule.class, RETURNS_DEEP_STUBS));
RuleMetaData ruleMetaData = new RuleMetaData(rules);
ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db",
mock(DatabaseType.class), resourceMetaData, ruleMetaData,
Collections.emptyMap());
database.reloadRules(MutableDataNodeRule.class);
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/GenericSchemaBuilderTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/GenericSchemaBuilderTest.java
index 992856e755c..cd1c47c6b8c 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/GenericSchemaBuilderTest.java
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/GenericSchemaBuilderTest.java
@@ -23,7 +23,7 @@ import
org.apache.shardingsphere.infra.database.core.metadata.data.loader.MetaDa
import
org.apache.shardingsphere.infra.database.core.metadata.data.model.SchemaMetaData;
import
org.apache.shardingsphere.infra.database.core.metadata.data.model.TableMetaData;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
-import
org.apache.shardingsphere.infra.metadata.database.schema.fixture.rule.TableContainedFixtureRule;
+import
org.apache.shardingsphere.infra.metadata.database.schema.fixture.rule.TableMapperContainedFixtureRule;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
@@ -60,7 +60,7 @@ class GenericSchemaBuilderTest {
DatabaseType databaseType =
TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
material = new GenericSchemaBuilderMaterial(databaseType,
Collections.singletonMap(DefaultDatabase.LOGIC_NAME, databaseType),
Collections.singletonMap(DefaultDatabase.LOGIC_NAME, new
MockedDataSource()),
- Collections.singleton(new TableContainedFixtureRule()), new
ConfigurationProperties(new Properties()), DefaultDatabase.LOGIC_NAME);
+ Collections.singleton(new TableMapperContainedFixtureRule()),
new ConfigurationProperties(new Properties()), DefaultDatabase.LOGIC_NAME);
}
@Test
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableMapperContainedFixtureRule.java
similarity index 57%
copy from
infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
copy to
infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableMapperContainedFixtureRule.java
index 91251a632ed..c4e7854a247 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableMapperContainedFixtureRule.java
@@ -18,31 +18,23 @@
package org.apache.shardingsphere.infra.metadata.database.schema.fixture.rule;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableNamesMapper;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableNamesMapper;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
-public final class TableContainedFixtureRule implements TableContainedRule {
+public final class TableMapperContainedFixtureRule implements
TableMapperContainedRule {
@Override
- public TableNamesMapper getLogicTableMapper() {
- return new TableNamesMapper();
- }
-
- @Override
- public TableNamesMapper getActualTableMapper() {
- return new TableNamesMapper();
- }
-
- @Override
- public TableNamesMapper getDistributedTableMapper() {
- return new TableNamesMapper();
- }
-
- @Override
- public TableNamesMapper getEnhancedTableMapper() {
- return new TableNamesMapper();
+ public TableMapperRule getTableMapperRule() {
+ TableMapperRule result = mock(TableMapperRule.class);
+ when(result.getLogicTableMapper()).thenReturn(new TableNamesMapper());
+ when(result.getActualTableMapper()).thenReturn(new TableNamesMapper());
+ when(result.getDistributedTableMapper()).thenReturn(new
TableNamesMapper());
+ when(result.getEnhancedTableMapper()).thenReturn(new
TableNamesMapper());
+ return result;
}
@Override
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/identifier/type/TableNamesMapperTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/identifier/type/TableNamesMapperTest.java
index c86070f5fee..a6ad177ac71 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/identifier/type/TableNamesMapperTest.java
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/identifier/type/TableNamesMapperTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.infra.rule.identifier.type;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableNamesMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
diff --git
a/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/refresher/type/table/DropTableStatementSchemaRefresher.java
b/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/refresher/type/table/DropTableStatementSchemaRefresher.java
index a3d23536c94..3eac95de6af 100644
---
a/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/refresher/type/table/DropTableStatementSchemaRefresher.java
+++
b/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/refresher/type/table/DropTableStatementSchemaRefresher.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.infra.instance.mode.ModeContextManager;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import
org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchemaMetaDataPOJO;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropTableStatement;
@@ -53,7 +53,7 @@ public final class DropTableStatementSchemaRefresher
implements MetaDataRefreshe
}
private boolean isSingleTable(final String tableName, final RuleMetaData
ruleMetaData) {
- return
ruleMetaData.findRules(TableContainedRule.class).stream().noneMatch(each ->
each.getDistributedTableMapper().contains(tableName));
+ return
ruleMetaData.findRules(TableMapperContainedRule.class).stream().noneMatch(each
-> each.getTableMapperRule().getDistributedTableMapper().contains(tableName));
}
@Override
diff --git
a/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/refresher/util/TableRefreshUtils.java
b/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/refresher/util/TableRefreshUtils.java
index 71e3170acd3..23be0f33eb0 100644
---
a/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/refresher/util/TableRefreshUtils.java
+++
b/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/refresher/util/TableRefreshUtils.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.infra.datanode.DataNode;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import
org.apache.shardingsphere.infra.rule.identifier.type.MutableDataNodeRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
import org.apache.shardingsphere.single.api.constant.SingleTableConstants;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
@@ -62,7 +62,7 @@ public final class TableRefreshUtils {
* @return whether single table
*/
public static boolean isSingleTable(final String tableName, final
ShardingSphereDatabase database) {
- return
database.getRuleMetaData().findRules(TableContainedRule.class).stream().noneMatch(each
-> each.getDistributedTableMapper().contains(tableName));
+ return
database.getRuleMetaData().findRules(TableMapperContainedRule.class).stream().noneMatch(each
-> each.getTableMapperRule().getDistributedTableMapper().contains(tableName));
}
/**
diff --git
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleRule.java
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleRule.java
index 443884a30f5..06fef5b4b10 100644
---
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleRule.java
+++
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleRule.java
@@ -31,10 +31,9 @@ import
org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.identifier.scope.DatabaseRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.MutableDataNodeRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableNamesMapper;
import
org.apache.shardingsphere.infra.rule.identifier.type.exportable.ExportableRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.exportable.constant.ExportableConstants;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.infra.state.datasource.DataSourceStateManager;
import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
import org.apache.shardingsphere.single.datanode.SingleTableDataNodeLoader;
@@ -55,7 +54,7 @@ import java.util.concurrent.ThreadLocalRandom;
/**
* Single rule.
*/
-public final class SingleRule implements DatabaseRule, DataNodeContainedRule,
TableContainedRule, MutableDataNodeRule, ExportableRule {
+public final class SingleRule implements DatabaseRule, DataNodeContainedRule,
TableMapperContainedRule, MutableDataNodeRule, ExportableRule {
@Getter
private final SingleRuleConfiguration configuration;
@@ -68,10 +67,11 @@ public final class SingleRule implements DatabaseRule,
DataNodeContainedRule, Ta
@Getter
private final Map<String, Collection<DataNode>> singleTableDataNodes;
- private final TableNamesMapper tableNamesMapper = new TableNamesMapper();
-
private final DatabaseType protocolType;
+ @Getter
+ private final SingleTableMapperRule tableMapperRule;
+
public SingleRule(final SingleRuleConfiguration ruleConfig, final String
databaseName, final DatabaseType protocolType, final Map<String, DataSource>
dataSourceMap,
final Collection<ShardingSphereRule> builtRules) {
configuration = ruleConfig;
@@ -81,7 +81,7 @@ public final class SingleRule implements DatabaseRule,
DataNodeContainedRule, Ta
dataSourceNames = aggregateDataSourceMap.keySet();
this.protocolType = protocolType;
singleTableDataNodes = SingleTableDataNodeLoader.load(databaseName,
protocolType, aggregateDataSourceMap, builtRules, configuration.getTables());
- singleTableDataNodes.forEach((key, value) ->
tableNamesMapper.put(value.iterator().next().getTableName()));
+ tableMapperRule = new SingleTableMapperRule(singleTableDataNodes);
}
/**
@@ -196,7 +196,7 @@ public final class SingleRule implements DatabaseRule,
DataNodeContainedRule, Ta
DataNode dataNode = new DataNode(dataSourceName, tableName);
dataNode.setSchemaName(schemaName);
dataNodes.add(dataNode);
- tableNamesMapper.put(tableName);
+ tableMapperRule.getLogicTableMapper().put(tableName);
addTableConfiguration(dataSourceName, schemaName, tableName);
}
}
@@ -234,7 +234,7 @@ public final class SingleRule implements DatabaseRule,
DataNodeContainedRule, Ta
}
if (dataNodes.isEmpty()) {
singleTableDataNodes.remove(tableName.toLowerCase());
- tableNamesMapper.remove(tableName);
+ tableMapperRule.getLogicTableMapper().remove(tableName);
}
}
@@ -285,28 +285,8 @@ public final class SingleRule implements DatabaseRule,
DataNodeContainedRule, Ta
return Optional.empty();
}
- @Override
- public TableNamesMapper getLogicTableMapper() {
- return tableNamesMapper;
- }
-
- @Override
- public TableNamesMapper getActualTableMapper() {
- return new TableNamesMapper();
- }
-
- @Override
- public TableNamesMapper getDistributedTableMapper() {
- return new TableNamesMapper();
- }
-
- @Override
- public TableNamesMapper getEnhancedTableMapper() {
- return new TableNamesMapper();
- }
-
@Override
public Map<String, Object> getExportData() {
- return
Collections.singletonMap(ExportableConstants.EXPORT_SINGLE_TABLES,
tableNamesMapper.getTableNames());
+ return
Collections.singletonMap(ExportableConstants.EXPORT_SINGLE_TABLES,
tableMapperRule.getLogicTableMapper().getTableNames());
}
}
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleTableMapperRule.java
similarity index 61%
rename from
infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
rename to
kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleTableMapperRule.java
index 91251a632ed..b2da473492e 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/fixture/rule/TableContainedFixtureRule.java
+++
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleTableMapperRule.java
@@ -15,19 +15,30 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.metadata.database.schema.fixture.rule;
+package org.apache.shardingsphere.single.rule;
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableNamesMapper;
+import org.apache.shardingsphere.infra.datanode.DataNode;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableNamesMapper;
-import static org.mockito.Mockito.mock;
+import java.util.Collection;
+import java.util.Map;
-public final class TableContainedFixtureRule implements TableContainedRule {
+/**
+ * Single table mapper rule.
+ */
+public final class SingleTableMapperRule implements TableMapperRule {
+
+ private final TableNamesMapper logicTableMapper;
+
+ public SingleTableMapperRule(final Map<String, Collection<DataNode>>
singleTableDataNodes) {
+ logicTableMapper = new TableNamesMapper();
+ singleTableDataNodes.forEach((key, value) ->
logicTableMapper.put(value.iterator().next().getTableName()));
+ }
@Override
public TableNamesMapper getLogicTableMapper() {
- return new TableNamesMapper();
+ return logicTableMapper;
}
@Override
@@ -44,9 +55,4 @@ public final class TableContainedFixtureRule implements
TableContainedRule {
public TableNamesMapper getEnhancedTableMapper() {
return new TableNamesMapper();
}
-
- @Override
- public RuleConfiguration getConfiguration() {
- return mock(RuleConfiguration.class);
- }
}
diff --git
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/util/SingleTableLoadUtils.java
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/util/SingleTableLoadUtils.java
index 2cb48112642..916348091c7 100644
---
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/util/SingleTableLoadUtils.java
+++
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/util/SingleTableLoadUtils.java
@@ -26,7 +26,7 @@ import
org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.single.api.constant.SingleTableConstants;
import javax.sql.DataSource;
@@ -84,11 +84,11 @@ public final class SingleTableLoadUtils {
public static Collection<String> getExcludedTables(final
Collection<ShardingSphereRule> builtRules) {
Collection<String> result = new
TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (ShardingSphereRule each : builtRules) {
- if (!(each instanceof TableContainedRule)) {
+ if (!(each instanceof TableMapperContainedRule)) {
continue;
}
- result.addAll(((TableContainedRule)
each).getDistributedTableMapper().getTableNames());
- result.addAll(((TableContainedRule)
each).getActualTableMapper().getTableNames());
+ result.addAll(((TableMapperContainedRule)
each).getTableMapperRule().getDistributedTableMapper().getTableNames());
+ result.addAll(((TableMapperContainedRule)
each).getTableMapperRule().getActualTableMapper().getTableNames());
}
return result;
}
@@ -102,14 +102,15 @@ public final class SingleTableLoadUtils {
public static Collection<String> getFeatureRequiredSingleTables(final
Collection<ShardingSphereRule> builtRules) {
Collection<String> result = new
TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (ShardingSphereRule each : builtRules) {
- if (!(each instanceof TableContainedRule)) {
+ if (!(each instanceof TableMapperContainedRule)) {
continue;
}
- TableContainedRule tableContainedRule = (TableContainedRule) each;
- if
(tableContainedRule.getEnhancedTableMapper().getTableNames().isEmpty() ||
!tableContainedRule.getDistributedTableMapper().getTableNames().isEmpty()) {
+ TableMapperContainedRule tableContainedRule =
(TableMapperContainedRule) each;
+ if
(tableContainedRule.getTableMapperRule().getEnhancedTableMapper().getTableNames().isEmpty()
+ ||
!tableContainedRule.getTableMapperRule().getDistributedTableMapper().getTableNames().isEmpty())
{
continue;
}
-
result.addAll(tableContainedRule.getEnhancedTableMapper().getTableNames());
+
result.addAll(tableContainedRule.getTableMapperRule().getEnhancedTableMapper().getTableNames());
}
return result;
}
diff --git
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoaderTest.java
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoaderTest.java
index 3cd144e60ab..2fa596724cd 100644
---
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoaderTest.java
+++
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/datanode/SingleTableDataNodeLoaderTest.java
@@ -21,7 +21,7 @@ import
org.apache.shardingsphere.infra.database.core.DefaultDatabase;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
import org.junit.jupiter.api.BeforeEach;
@@ -109,8 +109,8 @@ class SingleTableDataNodeLoaderTest {
private Collection<ShardingSphereRule> getBuiltRulesWithExcludedTables() {
Collection<String> excludedTables = Arrays.asList("salary",
"employee", "student");
- TableContainedRule tableContainedRule = mock(TableContainedRule.class,
RETURNS_DEEP_STUBS);
-
when(tableContainedRule.getDistributedTableMapper().getTableNames()).thenReturn(excludedTables);
+ TableMapperContainedRule tableContainedRule =
mock(TableMapperContainedRule.class, RETURNS_DEEP_STUBS);
+
when(tableContainedRule.getTableMapperRule().getDistributedTableMapper().getTableNames()).thenReturn(excludedTables);
return Collections.singletonList(tableContainedRule);
}
diff --git
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/SingleRuleTest.java
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/SingleRuleTest.java
index 1b107b9067b..01fd57e1cce 100644
---
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/SingleRuleTest.java
+++
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/SingleRuleTest.java
@@ -24,7 +24,7 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
import org.junit.jupiter.api.BeforeEach;
@@ -100,9 +100,9 @@ class SingleRuleTest {
@Test
void assertGetSingleTableDataNodes() {
- TableContainedRule tableContainedRule = mock(TableContainedRule.class,
RETURNS_DEEP_STUBS);
-
when(tableContainedRule.getDistributedTableMapper().getTableNames()).thenReturn(Collections.singletonList("t_order"));
-
when(tableContainedRule.getActualTableMapper().getTableNames()).thenReturn(Arrays.asList("t_order_0",
"t_order_1"));
+ TableMapperContainedRule tableContainedRule =
mock(TableMapperContainedRule.class, RETURNS_DEEP_STUBS);
+
when(tableContainedRule.getTableMapperRule().getDistributedTableMapper().getTableNames()).thenReturn(Collections.singletonList("t_order"));
+
when(tableContainedRule.getTableMapperRule().getActualTableMapper().getTableNames()).thenReturn(Arrays.asList("t_order_0",
"t_order_1"));
SingleRule singleRule = new SingleRule(ruleConfig,
DefaultDatabase.LOGIC_NAME, new H2DatabaseType(), dataSourceMap,
Collections.singleton(tableContainedRule));
Map<String, Collection<DataNode>> actual =
singleRule.getSingleTableDataNodes();
assertThat(actual.size(), is(2));
@@ -112,9 +112,9 @@ class SingleRuleTest {
@Test
void assertGetSingleTableDataNodesWithUpperCase() {
- TableContainedRule tableContainedRule = mock(TableContainedRule.class,
RETURNS_DEEP_STUBS);
-
when(tableContainedRule.getDistributedTableMapper().getTableNames()).thenReturn(Collections.singletonList("T_ORDER"));
-
when(tableContainedRule.getActualTableMapper().getTableNames()).thenReturn(Arrays.asList("T_ORDER_0",
"T_ORDER_1"));
+ TableMapperContainedRule tableContainedRule =
mock(TableMapperContainedRule.class, RETURNS_DEEP_STUBS);
+
when(tableContainedRule.getTableMapperRule().getDistributedTableMapper().getTableNames()).thenReturn(Collections.singleton("T_ORDER"));
+
when(tableContainedRule.getTableMapperRule().getActualTableMapper().getTableNames()).thenReturn(Arrays.asList("T_ORDER_0",
"T_ORDER_1"));
SingleRule singleRule = new SingleRule(ruleConfig,
DefaultDatabase.LOGIC_NAME, new H2DatabaseType(), dataSourceMap,
Collections.singleton(tableContainedRule));
Map<String, Collection<DataNode>> actual =
singleRule.getSingleTableDataNodes();
assertThat(actual.size(), is(2));
@@ -186,11 +186,11 @@ class SingleRuleTest {
tableNames.add(new QualifiedTable(DefaultDatabase.LOGIC_NAME,
"teacher"));
assertThat(singleRule.getSingleTables(tableNames).iterator().next().getSchemaName(),
is(DefaultDatabase.LOGIC_NAME));
assertThat(singleRule.getSingleTables(tableNames).iterator().next().getTableName(),
is("teacher"));
- assertTrue(singleRule.getLogicTableMapper().contains("employee"));
- assertTrue(singleRule.getLogicTableMapper().contains("student"));
- assertTrue(singleRule.getLogicTableMapper().contains("t_order_0"));
- assertTrue(singleRule.getLogicTableMapper().contains("t_order_1"));
- assertTrue(singleRule.getLogicTableMapper().contains("teacher"));
+
assertTrue(singleRule.getTableMapperRule().getLogicTableMapper().contains("employee"));
+
assertTrue(singleRule.getTableMapperRule().getLogicTableMapper().contains("student"));
+
assertTrue(singleRule.getTableMapperRule().getLogicTableMapper().contains("t_order_0"));
+
assertTrue(singleRule.getTableMapperRule().getLogicTableMapper().contains("t_order_1"));
+
assertTrue(singleRule.getTableMapperRule().getLogicTableMapper().contains("teacher"));
}
@Test
@@ -202,9 +202,9 @@ class SingleRuleTest {
Collection<QualifiedTable> tableNames = new LinkedList<>();
tableNames.add(new QualifiedTable(DefaultDatabase.LOGIC_NAME,
"employee"));
assertTrue(singleRule.getSingleTables(tableNames).isEmpty());
- assertTrue(singleRule.getLogicTableMapper().contains("student"));
- assertTrue(singleRule.getLogicTableMapper().contains("t_order_0"));
- assertTrue(singleRule.getLogicTableMapper().contains("t_order_1"));
+
assertTrue(singleRule.getTableMapperRule().getLogicTableMapper().contains("student"));
+
assertTrue(singleRule.getTableMapperRule().getLogicTableMapper().contains("t_order_0"));
+
assertTrue(singleRule.getTableMapperRule().getLogicTableMapper().contains("t_order_1"));
}
@Test
diff --git
a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/query/ShowUnloadedSingleTableExecutor.java
b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/query/ShowUnloadedSingleTableExecutor.java
index b3916182e2c..5857f32a2ce 100644
---
a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/query/ShowUnloadedSingleTableExecutor.java
+++
b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/query/ShowUnloadedSingleTableExecutor.java
@@ -57,7 +57,7 @@ public final class ShowUnloadedSingleTableExecutor implements
DistSQLQueryExecut
@Override
public Collection<LocalDataQueryResultRow> getRows(final
ShowUnloadedSingleTableStatement sqlStatement, final ContextManager
contextManager) {
Map<String, Collection<DataNode>> actualDataNodes =
getActualDataNodes(database);
- for (String each : rule.getLogicTableMapper().getTableNames()) {
+ for (String each :
rule.getTableMapperRule().getLogicTableMapper().getTableNames()) {
actualDataNodes.remove(each.toLowerCase());
}
return actualDataNodes.entrySet().stream().map(entry -> new
LocalDataQueryResultRow(entry.getKey(),
entry.getValue().iterator().next().getDataSourceName())).collect(Collectors.toList());
diff --git
a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/query/SingleCountResultRowBuilder.java
b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/query/SingleCountResultRowBuilder.java
index fb2cf0cc4e6..253120dea9a 100644
---
a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/query/SingleCountResultRowBuilder.java
+++
b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/query/SingleCountResultRowBuilder.java
@@ -31,7 +31,7 @@ public final class SingleCountResultRowBuilder implements
CountResultRowBuilder<
@Override
public Collection<LocalDataQueryResultRow> generateRows(final SingleRule
rule, final String databaseName) {
- return Collections.singleton(new LocalDataQueryResultRow("single",
databaseName, rule.getLogicTableMapper().getTableNames().size()));
+ return Collections.singleton(new LocalDataQueryResultRow("single",
databaseName,
rule.getTableMapperRule().getLogicTableMapper().getTableNames().size()));
}
@Override
diff --git
a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java
b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java
index 67b04a28ea0..b2299df06e8 100644
---
a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java
+++
b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/update/UnloadSingleTableExecutor.java
@@ -60,7 +60,7 @@ public final class UnloadSingleTableExecutor implements
DatabaseRuleAlterExecuto
}
Collection<String> allTables = getAllTableNames(database);
SingleRule singleRule =
database.getRuleMetaData().getSingleRule(SingleRule.class);
- Collection<String> singleTables =
singleRule.getLogicTableMapper().getTableNames();
+ Collection<String> singleTables =
singleRule.getTableMapperRule().getLogicTableMapper().getTableNames();
for (String each : sqlStatement.getTables()) {
checkTableExist(allTables, each);
checkIsSingleTable(singleTables, each);
diff --git
a/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/rule/TrafficRuleTest.java
b/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/rule/TrafficRuleTest.java
index b3284fabe67..af34c9885b5 100644
---
a/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/rule/TrafficRuleTest.java
+++
b/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/rule/TrafficRuleTest.java
@@ -26,7 +26,7 @@ import
org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionsSegment;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.CommentSegment;
@@ -99,7 +99,7 @@ class TrafficRuleTest {
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
-
when(result.getRuleMetaData().findRules(TableContainedRule.class)).thenReturn(Collections.emptyList());
+
when(result.getRuleMetaData().findRules(TableMapperContainedRule.class)).thenReturn(Collections.emptyList());
return result;
}
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ResourceMetaDataContextManager.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ResourceMetaDataContextManager.java
index 7a4ea3d7f18..2c18d994a5f 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ResourceMetaDataContextManager.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ResourceMetaDataContextManager.java
@@ -26,7 +26,7 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereView;
import org.apache.shardingsphere.infra.rule.identifier.type.MetaDataHeldRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.MutableDataNodeRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import java.util.Collections;
@@ -170,6 +170,6 @@ public final class ResourceMetaDataContextManager {
}
private boolean isSingleTable(final ShardingSphereDatabase database, final
String tableName) {
- return
database.getRuleMetaData().findRules(TableContainedRule.class).stream().noneMatch(each
-> each.getDistributedTableMapper().contains(tableName));
+ return
database.getRuleMetaData().findRules(TableMapperContainedRule.class).stream().noneMatch(each
-> each.getTableMapperRule().getDistributedTableMapper().contains(tableName));
}
}
diff --git
a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/NewStandaloneModeContextManager.java
b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/NewStandaloneModeContextManager.java
index ffe378f9550..51e3497473c 100644
---
a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/NewStandaloneModeContextManager.java
+++
b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/NewStandaloneModeContextManager.java
@@ -31,7 +31,7 @@ import
org.apache.shardingsphere.infra.metadata.version.MetaDataVersion;
import org.apache.shardingsphere.infra.rule.identifier.type.MetaDataHeldRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.MutableDataNodeRule;
import org.apache.shardingsphere.infra.rule.identifier.type.ResourceHeldRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import
org.apache.shardingsphere.infra.spi.type.ordered.cache.OrderedServicesCache;
import
org.apache.shardingsphere.metadata.persist.service.config.global.GlobalPersistService;
import
org.apache.shardingsphere.metadata.persist.service.database.DatabaseMetaDataBasedPersistService;
@@ -141,7 +141,7 @@ public final class NewStandaloneModeContextManager
implements ModeContextManager
}
private boolean isSingleTable(final String tableName, final
ShardingSphereDatabase database) {
- return
database.getRuleMetaData().findRules(TableContainedRule.class).stream().noneMatch(each
-> each.getDistributedTableMapper().contains(tableName));
+ return
database.getRuleMetaData().findRules(TableMapperContainedRule.class).stream().noneMatch(each
-> each.getTableMapperRule().getDistributedTableMapper().contains(tableName));
}
private void removeSchemaMetaData(final ShardingSphereDatabase database,
final String schemaName) {
diff --git
a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java
b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java
index 0be1c24658f..5c5b5fa401e 100644
---
a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java
+++
b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java
@@ -30,7 +30,7 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.pojo.AlterSchema
import org.apache.shardingsphere.infra.rule.identifier.type.MetaDataHeldRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.MutableDataNodeRule;
import org.apache.shardingsphere.infra.rule.identifier.type.ResourceHeldRule;
-import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
+import
org.apache.shardingsphere.infra.rule.identifier.type.table.TableMapperContainedRule;
import
org.apache.shardingsphere.infra.spi.type.ordered.cache.OrderedServicesCache;
import
org.apache.shardingsphere.metadata.persist.service.database.DatabaseMetaDataBasedPersistService;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -133,7 +133,7 @@ public final class StandaloneModeContextManager implements
ModeContextManager, C
}
private boolean isSingleTable(final String tableName, final
ShardingSphereDatabase database) {
- return
database.getRuleMetaData().findRules(TableContainedRule.class).stream().noneMatch(each
-> each.getDistributedTableMapper().contains(tableName));
+ return
database.getRuleMetaData().findRules(TableMapperContainedRule.class).stream().noneMatch(each
-> each.getTableMapperRule().getDistributedTableMapper().contains(tableName));
}
private void removeSchemaMetaData(final ShardingSphereDatabase database,
final String schemaName) {