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/12/30 11:09:52 UTC

[GitHub] [shardingsphere] Qianyi951015 opened a new pull request, #23207: add `count mask rule` DistSQL resultSet

Qianyi951015 opened a new pull request, #23207:
URL: https://github.com/apache/shardingsphere/pull/23207

   Ref: #23138.
   
   Changes proposed in this pull request:
     - add `count mask rule` DistSQL resultSet
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [x] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the pull request.
   - [x] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [ ] I have added corresponding unit tests for my changes.
   


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


[GitHub] [shardingsphere] RaigorJiang merged pull request #23207: add `count mask rule` DistSQL resultSet

Posted by GitBox <gi...@apache.org>.
RaigorJiang merged PR #23207:
URL: https://github.com/apache/shardingsphere/pull/23207


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


[GitHub] [shardingsphere] RaigorJiang commented on a diff in pull request #23207: add `count mask rule` DistSQL resultSet

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on code in PR #23207:
URL: https://github.com/apache/shardingsphere/pull/23207#discussion_r1059348767


##########
features/mask/distsql/statement/src/main/java/org/apache/shardingsphere/mask/distsql/parser/statement/CountMaskRuleStatement.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mask.distsql.parser.statement;
+
+import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowRulesStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DatabaseSegment;
+
+/**
+ * Count encrypt rule statement.

Review Comment:
   `encrypt` -> `mask`



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


[GitHub] [shardingsphere] codecov-commenter commented on pull request #23207: add `count mask rule` DistSQL resultSet

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #23207:
URL: https://github.com/apache/shardingsphere/pull/23207#issuecomment-1367873778

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/23207?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#23207](https://codecov.io/gh/apache/shardingsphere/pull/23207?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2c7e738) into [master](https://codecov.io/gh/apache/shardingsphere/commit/6055663498167f9f784a7935b90975e81077dafd?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (6055663) will **decrease** coverage by `0.02%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #23207      +/-   ##
   ============================================
   - Coverage     49.73%   49.71%   -0.03%     
     Complexity     2441     2441              
   ============================================
     Files          4017     4018       +1     
     Lines         57461    57483      +22     
     Branches       9117     9119       +2     
   ============================================
   - Hits          28577    28576       -1     
   - Misses        26349    26373      +24     
   + Partials       2535     2534       -1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/23207?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../distsql/handler/query/CountMaskRuleResultSet.java](https://codecov.io/gh/apache/shardingsphere/pull/23207/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvbWFzay9kaXN0c3FsL2hhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21hc2svZGlzdHNxbC9oYW5kbGVyL3F1ZXJ5L0NvdW50TWFza1J1bGVSZXN1bHRTZXQuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...stsql/parser/core/MaskDistSQLStatementVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/23207/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvbWFzay9kaXN0c3FsL3BhcnNlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvbWFzay9kaXN0c3FsL3BhcnNlci9jb3JlL01hc2tEaXN0U1FMU3RhdGVtZW50VmlzaXRvci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...handler/distsql/ral/hint/enums/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/23207/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2Rpc3RzcWwvcmFsL2hpbnQvZW51bXMvSGludFNvdXJjZVR5cGUuamF2YQ==) | `0.00% <0.00%> (-42.86%)` | :arrow_down: |
   | [...ontend/executor/ConnectionThreadExecutorGroup.java](https://codecov.io/gh/apache/shardingsphere/pull/23207/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvZnJvbnRlbmQvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvZnJvbnRlbmQvZXhlY3V0b3IvQ29ubmVjdGlvblRocmVhZEV4ZWN1dG9yR3JvdXAuamF2YQ==) | `86.66% <0.00%> (+13.33%)` | :arrow_up: |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


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


[GitHub] [shardingsphere] RaigorJiang commented on a diff in pull request #23207: add `count mask rule` DistSQL resultSet

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on code in PR #23207:
URL: https://github.com/apache/shardingsphere/pull/23207#discussion_r1059348916


##########
features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/CountMaskRuleResultSet.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mask.distsql.handler.query;
+
+import org.apache.shardingsphere.distsql.handler.resultset.DatabaseDistSQLResultSet;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.mask.distsql.parser.statement.CountMaskRuleStatement;
+import org.apache.shardingsphere.mask.rule.MaskRule;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.function.Supplier;
+
+/**
+ * Result set for count mask rule.
+ */
+public final class CountMaskRuleResultSet implements DatabaseDistSQLResultSet {
+    
+    private static final String MASK = "mask";
+    
+    private Iterator<Entry<String, LinkedList<Object>>> data = Collections.emptyIterator();
+    
+    @Override
+    public Collection<String> getColumnNames() {
+        return Arrays.asList("rule_name", "database", "count");
+    }
+    
+    @Override
+    public void init(final ShardingSphereDatabase database, final SQLStatement sqlStatement) {
+        Optional<MaskRule> rule = database.getRuleMetaData().findSingleRule(MaskRule.class);
+        Map<String, LinkedList<Object>> result = new LinkedHashMap<>();
+        rule.ifPresent(optional -> addEncryptData(result, database.getName(), rule.get()));
+        data = result.entrySet().iterator();
+    }
+    
+    private void addEncryptData(final Map<String, LinkedList<Object>> rowMap, final String databaseName, final MaskRule rule) {

Review Comment:
   Please update the method name.



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