This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 a6c1d0d4513 Refactor ShardingSphereSchema (#37893)
a6c1d0d4513 is described below
commit a6c1d0d4513e8b8a78820f3067124dbe0a16b3c4
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Jan 30 11:31:57 2026 +0800
Refactor ShardingSphereSchema (#37893)
---
.../metadata/database/schema/model/ShardingSphereSchema.java | 10 +++++-----
.../type/view/CreateViewPushDownMetaDataRefresherTest.java | 5 +++--
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java
index 7c5d2caa452..42d4f8a64d9 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java
@@ -35,28 +35,28 @@ public final class ShardingSphereSchema {
@Getter
private final String name;
+ @Getter
+ private final DatabaseType protocolType;
+
private final Map<ShardingSphereIdentifier, ShardingSphereTable> tables;
private final Map<ShardingSphereIdentifier, ShardingSphereView> views;
- @Getter
- private final DatabaseType protocolType;
-
@SuppressWarnings("CollectionWithoutInitialCapacity")
public ShardingSphereSchema(final String name, final DatabaseType
protocolType) {
this.name = name;
+ this.protocolType = protocolType;
tables = new ConcurrentHashMap<>();
views = new ConcurrentHashMap<>();
- this.protocolType = protocolType;
}
public ShardingSphereSchema(final String name, final
Collection<ShardingSphereTable> tables, final Collection<ShardingSphereView>
views, final DatabaseType protocolType) {
this.name = name;
+ this.protocolType = protocolType;
this.tables = new ConcurrentHashMap<>(tables.size(), 1F);
this.views = new ConcurrentHashMap<>(views.size(), 1F);
tables.forEach(each -> this.tables.put(new
ShardingSphereIdentifier(each.getName()), each));
views.forEach(each -> this.views.put(new
ShardingSphereIdentifier(each.getName()), each));
- this.protocolType = protocolType;
}
/**
diff --git
a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/CreateViewPushDownMetaDataRefresherTest.java
b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/CreateViewPushDownMetaDataRefresherTest.java
index be3e9bdc2fe..b9e88470f93 100644
---
a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/CreateViewPushDownMetaDataRefresherTest.java
+++
b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/CreateViewPushDownMetaDataRefresherTest.java
@@ -44,6 +44,7 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
+import java.sql.SQLException;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;
@@ -71,7 +72,7 @@ class CreateViewPushDownMetaDataRefresherTest {
private MutableDataNodeRuleAttribute mutableDataNodeRuleAttribute;
@Test
- void assertRefreshCreateViewWithSingleTableMapping() throws Exception {
+ void assertRefreshCreateViewWithSingleTableMapping() throws SQLException {
ShardingSphereRule rule = mock(ShardingSphereRule.class);
when(rule.getAttributes()).thenReturn(new
RuleAttributes(mutableDataNodeRuleAttribute));
ShardingSphereDatabase database = new ShardingSphereDatabase(
@@ -90,7 +91,7 @@ class CreateViewPushDownMetaDataRefresherTest {
}
@Test
- void assertRefreshCreateViewWithoutSingleTableMapping() throws Exception {
+ void assertRefreshCreateViewWithoutSingleTableMapping() throws
SQLException {
ShardingSphereRule rule = mock(ShardingSphereRule.class);
when(rule.getAttributes()).thenReturn(new
RuleAttributes(mutableDataNodeRuleAttribute));
ShardingSphereDatabase database = new ShardingSphereDatabase(