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/09 16:24:34 UTC

(shardingsphere) branch master updated: Refactor StreamDataParameter (#35934)

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 c0d5eaee9bd Refactor StreamDataParameter (#35934)
c0d5eaee9bd is described below

commit c0d5eaee9bd12b84b1bf3b7a3103d9a16b9f6a40
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Jul 10 00:24:27 2025 +0800

    Refactor StreamDataParameter (#35934)
    
    * Refactor StreamDataParameter
    
    * Refactor StreamDataParameter
---
 .../data/pipeline/core/datanode/JobDataNodeLineConvertUtils.java  | 8 ++++----
 .../pipeline/core/datanode/JobDataNodeLineConvertUtilsTest.java   | 8 ++++----
 .../apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPI.java    | 6 +++---
 .../shardingsphere/data/pipeline/cdc/api/StreamDataParameter.java | 2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtils.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtils.java
index 5692f107bf4..514d05b4167 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtils.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtils.java
@@ -40,12 +40,12 @@ public final class JobDataNodeLineConvertUtils {
     /**
      * Convert data nodes to lines.
      *
-     * @param actualDataNodes actual data nodes
-     * @return job data node line list.
+     * @param tableAndDataNodesMap table and data nodes map
+     * @return job data node line list
      */
-    public static List<JobDataNodeLine> convertDataNodesToLines(final Map<String, List<DataNode>> actualDataNodes) {
+    public static List<JobDataNodeLine> convertDataNodesToLines(final Map<String, List<DataNode>> tableAndDataNodesMap) {
         List<Pair<String, JobDataNodeLine>> result = new LinkedList<>();
-        for (Entry<String, Map<String, List<DataNode>>> entry : groupDataSourceDataNodesMapByDataSourceName(actualDataNodes).entrySet()) {
+        for (Entry<String, Map<String, List<DataNode>>> entry : groupDataSourceDataNodesMapByDataSourceName(tableAndDataNodesMap).entrySet()) {
             result.add(Pair.of(entry.getKey(), new JobDataNodeLine(getJobDataNodeEntries(entry.getValue()))));
         }
         // Sort by dataSourceName, make sure data node lines have the same ordering
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtilsTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtilsTest.java
index 2ae0b5792bb..19f9b37ef39 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtilsTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datanode/JobDataNodeLineConvertUtilsTest.java
@@ -35,12 +35,12 @@ class JobDataNodeLineConvertUtilsTest {
     
     @Test
     void assertConvertDataNodesToLines() {
-        Map<String, List<DataNode>> mockDataNodes = new LinkedHashMap<>(2, 1F);
+        Map<String, List<DataNode>> mockedTableAndDataNodesMap = new LinkedHashMap<>(2, 1F);
         List<DataNode> dataNodes = Arrays.asList(new DataNode("ds_0", "t_order_0"), new DataNode("ds_0", "t_order_1"));
         List<DataNode> itemDataNodes = Collections.singletonList(new DataNode("ds_0", "t_order_item_0"));
-        mockDataNodes.put("t_order", dataNodes);
-        mockDataNodes.put("t_order_item", itemDataNodes);
-        List<JobDataNodeLine> jobDataNodeLines = JobDataNodeLineConvertUtils.convertDataNodesToLines(mockDataNodes);
+        mockedTableAndDataNodesMap.put("t_order", dataNodes);
+        mockedTableAndDataNodesMap.put("t_order_item", itemDataNodes);
+        List<JobDataNodeLine> jobDataNodeLines = JobDataNodeLineConvertUtils.convertDataNodesToLines(mockedTableAndDataNodesMap);
         assertThat(jobDataNodeLines.size(), is(1));
         List<JobDataNodeEntry> actualNodeEntry = new ArrayList<>(jobDataNodeLines.get(0).getEntries());
         assertThat(actualNodeEntry.get(0).getLogicTableName(), is("t_order"));
diff --git a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPI.java b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPI.java
index 627ea0c990b..5bc6043bdda 100644
--- a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPI.java
+++ b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPI.java
@@ -157,10 +157,10 @@ public final class CDCJobAPI implements TransmissionJobAPI {
         result.setSinkConfig(sinkConfig);
         ShardingSphereDatabase database = PipelineContextManager.getContext(contextKey).getContextManager().getMetaDataContexts().getMetaData().getDatabase(param.getDatabaseName());
         result.setDataSourceConfiguration(pipelineDataSourceConfigSwapper.swapToYamlConfiguration(getDataSourceConfiguration(database)));
-        List<JobDataNodeLine> jobDataNodeLines = JobDataNodeLineConvertUtils.convertDataNodesToLines(param.getDataNodesMap());
+        List<JobDataNodeLine> jobDataNodeLines = JobDataNodeLineConvertUtils.convertDataNodesToLines(param.getTableAndDataNodesMap());
         result.setJobShardingDataNodes(jobDataNodeLines.stream().map(JobDataNodeLine::marshal).collect(Collectors.toList()));
-        JobDataNodeLine tableFirstDataNodes = new JobDataNodeLine(param.getDataNodesMap().entrySet().stream()
-                .map(each -> new JobDataNodeEntry(each.getKey(), each.getValue().subList(0, 1))).collect(Collectors.toList()));
+        JobDataNodeLine tableFirstDataNodes = new JobDataNodeLine(param.getTableAndDataNodesMap().entrySet().stream()
+                .map(entry -> new JobDataNodeEntry(entry.getKey(), entry.getValue().subList(0, 1))).collect(Collectors.toList()));
         result.setTablesFirstDataNodes(tableFirstDataNodes.marshal());
         result.setSourceDatabaseType(PipelineDataSourceConfigurationFactory.newInstance(
                 result.getDataSourceConfiguration().getType(), result.getDataSourceConfiguration().getParameter()).getDatabaseType().getType());
diff --git a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/StreamDataParameter.java b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/StreamDataParameter.java
index bd6c16a6595..72239dd54e0 100644
--- a/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/StreamDataParameter.java
+++ b/kernel/data-pipeline/scenario/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/api/StreamDataParameter.java
@@ -37,7 +37,7 @@ public final class StreamDataParameter {
     
     private final boolean isFull;
     
-    private final Map<String, List<DataNode>> dataNodesMap;
+    private final Map<String, List<DataNode>> tableAndDataNodesMap;
     
     private final boolean isDecodeWithTransaction;
 }