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 2022/09/16 02:01:53 UTC

[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #20938: Support audit declaration for create sharding table rule.

strongduanmu commented on code in PR #20938:
URL: https://github.com/apache/shardingsphere/pull/20938#discussion_r972546512


##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java:
##########
@@ -351,6 +358,33 @@ public ASTNode visitKeyGenerateDefinition(final KeyGenerateDefinitionContext ctx
         return null == ctx ? null : new KeyGenerateStrategySegment(getIdentifierValue(ctx.columnName()), (AlgorithmSegment) visit(ctx.algorithmDefinition()));
     }
     
+    @Override
+    public ASTNode visitAuditStrategy(final AuditStrategyContext ctx) {
+        if (null == ctx) {
+            return null;
+        }
+        List<String> auditorNames = new ArrayList<>();

Review Comment:
   Can we use Collection and LinkedList here?



##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java:
##########
@@ -249,6 +254,24 @@ private static void checkKeyGenerators(final Collection<AbstractTableRuleSegment
         DistSQLException.predictionThrow(invalidKeyGenerators.isEmpty(), () -> new InvalidAlgorithmConfigurationException("key generator", invalidKeyGenerators));
     }
     
+    private static void checkAuditors(final Collection<AbstractTableRuleSegment> rules, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+        Set<String> notExistAuditors = new LinkedHashSet<>();
+        Set<String> requiredAuditors = new LinkedHashSet<>();
+        List<AuditStrategySegment> auditStrategySegments = rules.stream().map(AbstractTableRuleSegment::getAuditStrategySegment).filter(Objects::nonNull).collect(Collectors.toList());

Review Comment:
   Can we use Collection here?



##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java:
##########
@@ -249,6 +254,24 @@ private static void checkKeyGenerators(final Collection<AbstractTableRuleSegment
         DistSQLException.predictionThrow(invalidKeyGenerators.isEmpty(), () -> new InvalidAlgorithmConfigurationException("key generator", invalidKeyGenerators));
     }
     
+    private static void checkAuditors(final Collection<AbstractTableRuleSegment> rules, final ShardingRuleConfiguration currentRuleConfig) throws DistSQLException {
+        Set<String> notExistAuditors = new LinkedHashSet<>();
+        Set<String> requiredAuditors = new LinkedHashSet<>();
+        List<AuditStrategySegment> auditStrategySegments = rules.stream().map(AbstractTableRuleSegment::getAuditStrategySegment).filter(Objects::nonNull).collect(Collectors.toList());
+        List<String> auditorNames = new ArrayList<>();

Review Comment:
   Use `new LinkedList<>()` may be better.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org