You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by yx...@apache.org on 2022/04/18 15:17:47 UTC

[shardingsphere] branch master updated: Remove @Builder for DataConsistencyCalculateParameter (#16909)

This is an automated email from the ASF dual-hosted git repository.

yx9o 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 067940bcc7a Remove @Builder for DataConsistencyCalculateParameter (#16909)
067940bcc7a is described below

commit 067940bcc7a794265bff82d3aa4ebe50611f8e78
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Apr 18 23:17:37 2022 +0800

    Remove @Builder for DataConsistencyCalculateParameter (#16909)
---
 .../consistency/DataConsistencyCheckerImpl.java    | 11 ++++-----
 ...MatchDataConsistencyCalculateAlgorithmTest.java |  3 +--
 .../DataConsistencyCalculateParameter.java         | 28 +++++++---------------
 3 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyCheckerImpl.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyCheckerImpl.java
index 9882fb742e9..e4c69c65790 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyCheckerImpl.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/DataConsistencyCheckerImpl.java
@@ -168,8 +168,8 @@ public final class DataConsistencyCheckerImpl implements DataConsistencyChecker
                 TableMetaData tableMetaData = tableMetaDataMap.get(each);
                 Collection<String> columnNames = tableMetaData.getColumns().keySet();
                 String uniqueKey = tableMetaData.getPrimaryKeyColumns().get(0);
-                DataConsistencyCalculateParameter sourceParameter = buildParameter(sourceDataSource, sourceDatabaseType, targetDatabaseType, each, columnNames, uniqueKey);
-                DataConsistencyCalculateParameter targetParameter = buildParameter(targetDataSource, targetDatabaseType, sourceDatabaseType, each, columnNames, uniqueKey);
+                DataConsistencyCalculateParameter sourceParameter = buildParameter(sourceDataSource, each, columnNames, sourceDatabaseType, targetDatabaseType, uniqueKey);
+                DataConsistencyCalculateParameter targetParameter = buildParameter(targetDataSource, each, columnNames, targetDatabaseType, sourceDatabaseType, uniqueKey);
                 Iterator<Object> sourceCalculatedResults = dataConsistencyCalculator.calculate(sourceParameter).iterator();
                 Iterator<Object> targetCalculatedResults = dataConsistencyCalculator.calculate(targetParameter).iterator();
                 boolean calculateResultsEquals = true;
@@ -222,9 +222,8 @@ public final class DataConsistencyCheckerImpl implements DataConsistencyChecker
         }
     }
     
-    private DataConsistencyCalculateParameter buildParameter(final PipelineDataSourceWrapper sourceDataSource, final String sourceDatabaseType,
-                                                             final String targetDatabaseType, final String tableName, final Collection<String> columnNames, final String uniqueKey) {
-        return DataConsistencyCalculateParameter.builder().dataSource(sourceDataSource).databaseType(sourceDatabaseType)
-                .peerDatabaseType(targetDatabaseType).logicTableName(tableName).columnNames(columnNames).uniqueKey(uniqueKey).build();
+    private DataConsistencyCalculateParameter buildParameter(final PipelineDataSourceWrapper sourceDataSource, final String tableName, final Collection<String> columnNames, 
+                                                             final String sourceDatabaseType, final String targetDatabaseType, final String uniqueKey) {
+        return new DataConsistencyCalculateParameter(sourceDataSource, tableName, columnNames, sourceDatabaseType, targetDatabaseType, uniqueKey);
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/spi/check/consistency/CRC32MatchDataConsistencyCalculateAlgorithmTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/spi/check/consistency/CRC32MatchDataConsistencyCalculateAlgorithmTest.java
index 72d660dc82a..791b7d223c7 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/spi/check/consistency/CRC32MatchDataConsistencyCalculateAlgorithmTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/spi/check/consistency/CRC32MatchDataConsistencyCalculateAlgorithmTest.java
@@ -55,8 +55,7 @@ public final class CRC32MatchDataConsistencyCalculateAlgorithmTest {
     
     @Before
     public void setUp() throws SQLException {
-        parameter = DataConsistencyCalculateParameter.builder()
-                .logicTableName("foo_tbl").columnNames(Arrays.asList("foo_col", "bar_col")).dataSource(pipelineDataSource).databaseType("FIXTURE").build();
+        parameter = new DataConsistencyCalculateParameter(pipelineDataSource, "foo_tbl", Arrays.asList("foo_col", "bar_col"), "FIXTURE", "FIXTURE", "1");
         when(pipelineDataSource.getConnection()).thenReturn(connection);
     }
     
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/api/check/consistency/DataConsistencyCalculateParameter.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/api/check/consistency/DataConsistencyCalculateParameter.java
index 3bce12ec0a6..4ba13f73551 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/api/check/consistency/DataConsistencyCalculateParameter.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-spi/src/main/java/org/apache/shardingsphere/data/pipeline/api/check/consistency/DataConsistencyCalculateParameter.java
@@ -18,8 +18,8 @@
 package org.apache.shardingsphere.data.pipeline.api.check.consistency;
 
 import com.google.common.collect.Range;
-import lombok.Builder;
 import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 import lombok.Setter;
 import lombok.ToString;
 import org.apache.shardingsphere.data.pipeline.api.datasource.PipelineDataSourceWrapper;
@@ -29,9 +29,9 @@ import java.util.Collection;
 /**
  * Data consistency calculate parameter.
  */
+@RequiredArgsConstructor
 @Getter
 @Setter
-@Builder
 @ToString
 public final class DataConsistencyCalculateParameter {
     
@@ -39,33 +39,21 @@ public final class DataConsistencyCalculateParameter {
      * Data source of source side or target side.
      * Do not close it, it will be reused later.
      */
-    private PipelineDataSourceWrapper dataSource;
+    private final PipelineDataSourceWrapper dataSource;
     
-    /**
-     * Logic table name.
-     */
-    private String logicTableName;
+    private final String logicTableName;
     
-    /**
-     * All column names of logic table.
-     */
-    private Collection<String> columnNames;
+    private final Collection<String> columnNames;
     
-    /**
-     * Database type.
-     */
-    private String databaseType;
+    private final String databaseType;
     
-    /**
-     * Peer database type.
-     */
-    private String peerDatabaseType;
+    private final String peerDatabaseType;
     
     /**
      * It could be primary key.
      * It could be used in order by clause.
      */
-    private String uniqueKey;
+    private final String uniqueKey;
     
     /**
      * Used for range query.