You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2025/07/10 13:28:00 UTC

(shardingsphere) branch master updated: Refactor TableMapperRuleAttribute (#35945)

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 0d87ae51628 Refactor TableMapperRuleAttribute (#35945)
0d87ae51628 is described below

commit 0d87ae51628587d26e4539feac9345bf6a12f655
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Jul 10 21:27:54 2025 +0800

    Refactor TableMapperRuleAttribute (#35945)
---
 .../rule/attribute/EncryptTableMapperRuleAttribute.java     |  8 ++++----
 .../mask/rule/attribute/MaskTableMapperRuleAttribute.java   |  6 +++---
 .../rule/attribute/ShardingTableNamesRuleAttribute.java     |  2 +-
 .../single/rule/SingleTableMapperRuleAttribute.java         | 13 +++++++++----
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttribute.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttribute.java
index 552f41c8653..97ee6ac8301 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttribute.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/attribute/EncryptTableMapperRuleAttribute.java
@@ -28,15 +28,15 @@ import java.util.Collections;
  */
 public final class EncryptTableMapperRuleAttribute implements TableMapperRuleAttribute {
     
-    private final Collection<String> logicalTableMapper;
+    private final Collection<String> logicalTableNames;
     
     public EncryptTableMapperRuleAttribute(final Collection<String> encryptTableNames) {
-        logicalTableMapper = new CaseInsensitiveSet<>(encryptTableNames);
+        logicalTableNames = new CaseInsensitiveSet<>(encryptTableNames);
     }
     
     @Override
     public Collection<String> getLogicTableNames() {
-        return logicalTableMapper;
+        return logicalTableNames;
     }
     
     @Override
@@ -46,6 +46,6 @@ public final class EncryptTableMapperRuleAttribute implements TableMapperRuleAtt
     
     @Override
     public Collection<String> getEnhancedTableNames() {
-        return logicalTableMapper;
+        return logicalTableNames;
     }
 }
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttribute.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttribute.java
index 7354706ca9f..e66ca119d5e 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttribute.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/attribute/MaskTableMapperRuleAttribute.java
@@ -28,15 +28,15 @@ import java.util.Collections;
  */
 public final class MaskTableMapperRuleAttribute implements TableMapperRuleAttribute {
     
-    private final Collection<String> logicalTableMapper;
+    private final Collection<String> logicalTableNames;
     
     public MaskTableMapperRuleAttribute(final Collection<String> maskTableNames) {
-        logicalTableMapper = new CaseInsensitiveSet<>(maskTableNames);
+        logicalTableNames = new CaseInsensitiveSet<>(maskTableNames);
     }
     
     @Override
     public Collection<String> getLogicTableNames() {
-        return logicalTableMapper;
+        return logicalTableNames;
     }
     
     @Override
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/attribute/ShardingTableNamesRuleAttribute.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/attribute/ShardingTableNamesRuleAttribute.java
index 4426ca708fc..bca990b8d1b 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/attribute/ShardingTableNamesRuleAttribute.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/attribute/ShardingTableNamesRuleAttribute.java
@@ -39,7 +39,7 @@ public final class ShardingTableNamesRuleAttribute implements TableMapperRuleAtt
     }
     
     private Collection<String> createLogicalTableNames(final Collection<ShardingTable> shardingTables) {
-        Collection<String> result = new CaseInsensitiveSet<>();
+        Collection<String> result = new CaseInsensitiveSet<>(shardingTables.size());
         shardingTables.forEach(each -> result.add(each.getLogicTable()));
         return result;
     }
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleTableMapperRuleAttribute.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleTableMapperRuleAttribute.java
index ae69652c2fd..bb50b89c5ef 100644
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleTableMapperRuleAttribute.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/rule/SingleTableMapperRuleAttribute.java
@@ -29,16 +29,21 @@ import java.util.Collections;
  */
 public final class SingleTableMapperRuleAttribute implements TableMapperRuleAttribute {
     
-    private final Collection<String> logicTableMapper;
+    private final Collection<String> logicalTableNames;
     
     public SingleTableMapperRuleAttribute(final Collection<Collection<DataNode>> singleTableDataNodes) {
-        logicTableMapper = new CaseInsensitiveSet<>(singleTableDataNodes.size(), 1F);
-        singleTableDataNodes.forEach(each -> logicTableMapper.add(each.iterator().next().getTableName()));
+        logicalTableNames = createLogicalTableNames(singleTableDataNodes);
+    }
+    
+    private Collection<String> createLogicalTableNames(final Collection<Collection<DataNode>> singleTableDataNodes) {
+        Collection<String> result = new CaseInsensitiveSet<>(singleTableDataNodes.size(), 1F);
+        singleTableDataNodes.forEach(each -> result.add(each.iterator().next().getTableName()));
+        return result;
     }
     
     @Override
     public Collection<String> getLogicTableNames() {
-        return logicTableMapper;
+        return logicalTableNames;
     }
     
     @Override