From b5fecd529ced73891769d9521dbf70337da6f920 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Thu, 2 Nov 2023 22:38:10 +0800 Subject: [PATCH] Refactor DumperConfiguration --- .../api/config/ingest/DumperConfiguration.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/config/ingest/DumperConfiguration.java b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/config/ingest/DumperConfiguration.java index 45b77d4a2c187..f38bf55d6fd53 100644 --- a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/config/ingest/DumperConfiguration.java +++ b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/config/ingest/DumperConfiguration.java @@ -30,6 +30,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -58,7 +59,7 @@ public class DumperConfiguration { // LinkedHashSet is required @Getter(AccessLevel.PROTECTED) - private Map> targetTableColumnsMap; + private Map> targetTableColumnsMap = new HashMap<>(); private boolean decodeWithTX; @@ -113,8 +114,9 @@ public String getSchemaName(final ActualTableName actualTableName) { * @return column names */ public Collection getColumnNames(final LogicTableName logicTableName) { - Collection columnNames = null == targetTableColumnsMap ? null : targetTableColumnsMap.get(logicTableName); - return null == columnNames ? Collections.singleton("*") : columnNames.stream().map(ColumnName::getOriginal).collect(Collectors.toList()); + return targetTableColumnsMap.containsKey(logicTableName) + ? targetTableColumnsMap.get(logicTableName).stream().map(ColumnName::getOriginal).collect(Collectors.toList()) + : Collections.singleton("*"); } /** @@ -124,7 +126,6 @@ public Collection getColumnNames(final LogicTableName logicTableName) { * @return column names */ public Collection getColumnNames(final String actualTableName) { - Set result = null == targetTableColumnsMap ? null : targetTableColumnsMap.get(getLogicTableName(actualTableName)); - return null == result ? Collections.emptySet() : result; + return targetTableColumnsMap.getOrDefault(getLogicTableName(actualTableName), Collections.emptySet()); } }