This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 b4f24bf6a5e remove useless constructor for `AutoTableRuleSegment`
(#23449)
b4f24bf6a5e is described below
commit b4f24bf6a5ea60a24c69ff863e368bd9a59d20f0
Author: Zichao <[email protected]>
AuthorDate: Tue Jan 10 05:40:25 2023 +1300
remove useless constructor for `AutoTableRuleSegment` (#23449)
---
.../checker/ShardingRuleStatementCheckerTest.java | 12 ++++++++----
.../ShardingRuleStatementConverterTest.java | 22 ++++++++++++----------
.../parser/segment/table/AutoTableRuleSegment.java | 10 ----------
3 files changed, 20 insertions(+), 24 deletions(-)
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
index 796302cb94b..839259aed34 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
@@ -100,10 +100,14 @@ public final class ShardingRuleStatementCheckerTest {
ShardingRuleConfiguration shardingRuleConfig =
createShardingRuleConfiguration();
shardingRuleConfig.getBindingTableGroups().add(new
ShardingTableReferenceRuleConfiguration("reference_0", "t_order,t_order_item"));
Collection<AbstractTableRuleSegment> rules = new LinkedList<>();
- rules.add(new AutoTableRuleSegment("t_order", Arrays.asList("ds_0",
"ds_1"), "order_id",
- new AlgorithmSegment("CORE.AUTO.FIXTURE",
PropertiesBuilder.build(new Property("sharding-count", "2"))), null, null));
- rules.add(new AutoTableRuleSegment("t_order_item",
Arrays.asList("ds_0", "ds_1"), "order_id",
- new AlgorithmSegment("CORE.AUTO.FIXTURE",
PropertiesBuilder.build(new Property("sharding-count", "2"))), null, null));
+ AutoTableRuleSegment autoTable1 = new AutoTableRuleSegment("t_order",
Arrays.asList("ds_0", "ds_1"));
+ autoTable1.setShardingColumn("order_id");
+ autoTable1.setShardingAlgorithmSegment(new
AlgorithmSegment("CORE.AUTO.FIXTURE", PropertiesBuilder.build(new
Property("sharding-count", "2"))));
+ rules.add(autoTable1);
+ AutoTableRuleSegment autoTable2 = new
AutoTableRuleSegment("t_order_item", Arrays.asList("ds_0", "ds_1"));
+ autoTable2.setShardingColumn("order_id");
+ autoTable2.setShardingAlgorithmSegment(new
AlgorithmSegment("CORE.AUTO.FIXTURE", PropertiesBuilder.build(new
Property("sharding-count", "2"))));
+ rules.add(autoTable2);
ShardingTableRuleStatementChecker.checkAlteration(database, rules,
shardingRuleConfig);
}
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java
index 3bc467cee8d..e24102aaf01 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java
@@ -76,16 +76,15 @@ public final class ShardingRuleStatementConverterTest {
}
private Collection<AbstractTableRuleSegment> createTableRuleSegment1() {
- Collection<AbstractTableRuleSegment> result = new LinkedList<>();
- AutoTableRuleSegment autoTableRuleSegment1 = new
AutoTableRuleSegment("t_order", Arrays.asList("ds0", "ds1"), "order_id",
- new AlgorithmSegment("MOD", PropertiesBuilder.build(new
Property("sharding_count", "2"))), null, null);
- result.add(autoTableRuleSegment1);
- AutoTableRuleSegment autoTableRuleSegment2 = new
AutoTableRuleSegment("t_order_2", Arrays.asList("ds0", "ds1"), "order_id",
- new AlgorithmSegment("MOD", PropertiesBuilder.build(new
Property("sharding_count", "2"))),
- new KeyGenerateStrategySegment("order_id",
"snowflake_algorithm"),
- new AuditStrategySegment(Collections.singleton(new
ShardingAuditorSegment("sharding_key_required_auditor",
- new AlgorithmSegment("DML_SHARDING_CONDITIONS", new
Properties()))), true));
- result.add(autoTableRuleSegment2);
+ AutoTableRuleSegment autoTableRuleSegment1 = new
AutoTableRuleSegment("t_order", Arrays.asList("ds0", "ds1"));
+ autoTableRuleSegment1.setShardingColumn("order_id");
+ autoTableRuleSegment1.setShardingAlgorithmSegment(new
AlgorithmSegment("MOD", PropertiesBuilder.build(new Property("sharding_count",
"2"))));
+ AutoTableRuleSegment autoTableRuleSegment2 = new
AutoTableRuleSegment("t_order_2", Arrays.asList("ds0", "ds1"));
+ autoTableRuleSegment2.setShardingColumn("order_id");
+ autoTableRuleSegment2.setShardingAlgorithmSegment(new
AlgorithmSegment("MOD", PropertiesBuilder.build(new Property("sharding_count",
"2"))));
+ autoTableRuleSegment2.setKeyGenerateStrategySegment(new
KeyGenerateStrategySegment("order_id", "snowflake_algorithm"));
+ autoTableRuleSegment2.setAuditStrategySegment(new
AuditStrategySegment(Collections.singleton(new
ShardingAuditorSegment("sharding_key_required_auditor",
+ new AlgorithmSegment("DML_SHARDING_CONDITIONS", new
Properties()))), true));
TableRuleSegment tableRuleSegment = new TableRuleSegment("t_order",
Arrays.asList("ds0", "ds1"),
new KeyGenerateStrategySegment("order_id", new
AlgorithmSegment("snowflake", PropertiesBuilder.build(new Property("", "")))),
new AuditStrategySegment(Collections.singleton(new
ShardingAuditorSegment("sharding_key_required_auditor",
@@ -93,6 +92,9 @@ public final class ShardingRuleStatementConverterTest {
AlgorithmSegment databaseAlgorithmSegment = new
AlgorithmSegment("inline", PropertiesBuilder.build(new
Property("algorithm-expression", "ds_${product_id % 2}")));
tableRuleSegment.setDatabaseStrategySegment(new
ShardingStrategySegment("standard", "order_id", databaseAlgorithmSegment));
tableRuleSegment.setTableStrategySegment(new
ShardingStrategySegment("standard", "order_id", new
AlgorithmSegment("order_id_algorithm", new Properties())));
+ Collection<AbstractTableRuleSegment> result = new LinkedList<>();
+ result.add(autoTableRuleSegment1);
+ result.add(autoTableRuleSegment2);
result.add(tableRuleSegment);
return result;
}
diff --git
a/features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/segment/table/AutoTableRuleSegment.java
b/features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/segment/table/AutoTableRuleSegment.java
index 64f876f9e67..1a0616a33a5 100644
---
a/features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/segment/table/AutoTableRuleSegment.java
+++
b/features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/segment/table/AutoTableRuleSegment.java
@@ -20,8 +20,6 @@ package
org.apache.shardingsphere.sharding.distsql.parser.segment.table;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
-import
org.apache.shardingsphere.sharding.distsql.parser.segment.strategy.AuditStrategySegment;
-import
org.apache.shardingsphere.sharding.distsql.parser.segment.strategy.KeyGenerateStrategySegment;
import java.util.Collection;
@@ -39,12 +37,4 @@ public final class AutoTableRuleSegment extends
AbstractTableRuleSegment {
public AutoTableRuleSegment(final String logicTable, final
Collection<String> dataSources) {
super(logicTable, dataSources);
}
-
- public AutoTableRuleSegment(final String logicTable, final
Collection<String> dataSources, final String shardingColumn,
- final AlgorithmSegment shardingAlgorithm,
final KeyGenerateStrategySegment keyGenerateStrategySegment,
- final AuditStrategySegment
auditStrategySegment) {
- super(logicTable, dataSources, keyGenerateStrategySegment,
auditStrategySegment);
- this.shardingColumn = shardingColumn;
- this.shardingAlgorithmSegment = shardingAlgorithm;
- }
}