You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by xi...@apache.org on 2020/09/27 10:43:33 UTC

[shardingsphere] branch master updated: minor refactor (#7618)

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

xiaoyu 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 2725980  minor refactor (#7618)
2725980 is described below

commit 2725980d4f3647f3653479cf82c9b42302772451
Author: kimmking <ki...@163.com>
AuthorDate: Sun Sep 27 18:43:19 2020 +0800

    minor refactor (#7618)
---
 .../sql/context/ExecutionContextBuilder.java         | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java
index 6296e4a..101a6bc 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java
@@ -87,10 +87,7 @@ public final class ExecutionContextBuilder {
     }
     
     private static List<String> getLogicTableNames(final Collection<RouteMapper> tableMappers) {
-        if (null == tableMappers) {
-            return Collections.emptyList();
-        }
-        return tableMappers.stream().map(RouteMapper::getLogicName).collect(Collectors.toList());
+        return null == tableMappers ? Collections.emptyList() : tableMappers.stream().map(RouteMapper::getLogicName).collect(Collectors.toList());
     }
     
     private static List<String> getActualTableNames(final SQLStatementContext<?> sqlStatementContext) {
@@ -116,6 +113,10 @@ public final class ExecutionContextBuilder {
         return getPrimaryKeyColumns(metaData, getActualTableNames(sqlStatementContext));
     }
     
+    private static List<PrimaryKeyMetaData> getPrimaryKeyColumns(final ShardingSphereMetaData metaData, final Collection<RouteMapper> tableMappers) {
+        return getPrimaryKeyColumns(metaData, getLogicTableNames(tableMappers));
+    }
+    
     private static List<PrimaryKeyMetaData> getPrimaryKeyColumns(final ShardingSphereMetaData metaData, final List<String> actualTableNames) {
         List<PrimaryKeyMetaData> result = new LinkedList<>();
         for (String each: actualTableNames) {
@@ -126,15 +127,4 @@ public final class ExecutionContextBuilder {
         }
         return result;
     }
-    
-    private static List<PrimaryKeyMetaData> getPrimaryKeyColumns(final ShardingSphereMetaData metaData, final Collection<RouteMapper> tableMappers) {
-        List<PrimaryKeyMetaData> result = new LinkedList<>();
-        for (RouteMapper each: tableMappers) {
-            TableMetaData tableMetaData = metaData.getRuleSchemaMetaData().getSchemaMetaData().get(each.getLogicName());
-            if (null != tableMetaData) {
-                result.add(new PrimaryKeyMetaData(each.getLogicName(), tableMetaData.getPrimaryKeyColumns()));
-            }
-        }
-        return result;
-    }
 }