You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/09/24 03:44:08 UTC

[GitHub] [incubator-shardingsphere] betterjava commented on a change in pull request #3086: support query hint context for sharding-proxy

betterjava commented on a change in pull request #3086: support query hint context for sharding-proxy
URL: https://github.com/apache/incubator-shardingsphere/pull/3086#discussion_r327415882
 
 

 ##########
 File path: sharding-proxy/sharding-proxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/text/sctl/hint/internal/HintCommandExecutorFactory.java
 ##########
 @@ -46,30 +51,53 @@
     /**
      * Create hint command executor instance.
      *
-     * @param sql SQL
+     * @param shardingRule sharding rule
+     * @param sql          SQL
      * @return hint command executor
      */
-    public static HintCommandExecutor newInstance(final String sql) {
+    public static HintCommandExecutor newInstance(final ShardingRule shardingRule, final String sql) {
         Optional<ShardingCTLHintStatement> shardingTCLStatement = new ShardingCTLHintParser(sql).doParse();
         if (!shardingTCLStatement.isPresent()) {
             return new HintErrorFormatExecutor(sql);
         }
         HintCommand hintCommand = shardingTCLStatement.get().getHintCommand();
+        Optional<HintCommandExecutor> hintUpdateExecutor = getHintUpdateExecutor(hintCommand);
+        if (hintUpdateExecutor.isPresent()) {
+            return hintUpdateExecutor.get();
+        }
+        Optional<HintCommandExecutor> hintQueryExecutor = getHintQueryExecutor(hintCommand, shardingRule);
+        if (hintQueryExecutor.isPresent()) {
+            return hintQueryExecutor.get();
+        }
+        return new HintErrorParameterExecutor(sql);
+    }
+    
+    private static Optional<HintCommandExecutor> getHintUpdateExecutor(final HintCommand hintCommand) {
 
 Review comment:
   The reason I split them into two methods is because checkstyle prompts me that the method branch is too complex.
   So Can I ignore this warning?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services