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/02/02 03:55:47 UTC

[GitHub] [shardingsphere] zjcnb opened a new pull request #15234: Adjust get single table data source name mapping.

zjcnb opened a new pull request #15234:
URL: https://github.com/apache/shardingsphere/pull/15234


   Fixes #15191, #15207 


-- 
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] strongduanmu merged pull request #15234: Adjust get single table data source name mapping.

Posted by GitBox <gi...@apache.org>.
strongduanmu merged pull request #15234:
URL: https://github.com/apache/shardingsphere/pull/15234


   


-- 
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] zjcnb commented on a change in pull request #15234: Adjust get single table data source name mapping.

Posted by GitBox <gi...@apache.org>.
zjcnb commented on a change in pull request #15234:
URL: https://github.com/apache/shardingsphere/pull/15234#discussion_r797613979



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/MutableDataNodeRule.java
##########
@@ -42,9 +43,10 @@
     void remove(String tableName);
     
     /**
-     * Get data source names.
+     * Find single data node by table name.
      *
-     * @return Get data source names
+     * @param tableName table name
+     * @return single table data node
      */
-    Collection<String> getDataSourceNames();
+    Optional<DataNode> findSingleTableDataNodeByTableName(String tableName);

Review comment:
       Yes, I will adjust it.




-- 
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] zjcnb commented on a change in pull request #15234: Adjust get single table data source name mapping.

Posted by GitBox <gi...@apache.org>.
zjcnb commented on a change in pull request #15234:
URL: https://github.com/apache/shardingsphere/pull/15234#discussion_r797616487



##########
File path: shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
##########
@@ -251,9 +251,7 @@ public void alterSchema(final String schemaName, final ShardingSphereSchema sche
      */
     public void alterSchema(final String schemaName, final TableMetaData changedTableMetaData, final String deletedTable) {
         ShardingSphereMetaData metaData = metaDataContexts.getMetaData(schemaName);
-        if (!containsInDataNodeContainedRule(changedTableMetaData.getName(), metaData)) {
-            metaData.getRuleMetaData().findRules(MutableDataNodeRule.class).forEach(each -> each.put(changedTableMetaData.getName(), each.getDataSourceNames().iterator().next()));
-        }
+        singleTableDataSourceMappingRelation(metaData, changedTableMetaData);

Review comment:
       Yes, it' s a good idea.




-- 
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 #15234: Adjust get single table data source name mapping.

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


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/15234?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 [#15234](https://codecov.io/gh/apache/shardingsphere/pull/15234?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (12d3c90) into [master](https://codecov.io/gh/apache/shardingsphere/commit/8a50d171f004b6f8b89229b965685910f0184e74?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8a50d17) will **decrease** coverage by `0.01%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/15234/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/15234?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #15234      +/-   ##
   ============================================
   - Coverage     60.12%   60.11%   -0.02%     
   + Complexity     1941     1940       -1     
   ============================================
     Files          3183     3183              
     Lines         47581    47586       +5     
     Branches       8089     8090       +1     
   ============================================
   - Hits          28610    28606       -4     
   - Misses        16658    16667       +9     
     Partials       2313     2313              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/15234?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ardingsphere/singletable/rule/SingleTableRule.java](https://codecov.io/gh/apache/shardingsphere/pull/15234/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-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXNpbmdsZS10YWJsZS9zaGFyZGluZ3NwaGVyZS1zaW5nbGUtdGFibGUtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2luZ2xldGFibGUvcnVsZS9TaW5nbGVUYWJsZVJ1bGUuamF2YQ==) | `71.23% <0.00%> (-1.37%)` | :arrow_down: |
   | [...he/shardingsphere/mode/manager/ContextManager.java](https://codecov.io/gh/apache/shardingsphere/pull/15234/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-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbWFuYWdlci9Db250ZXh0TWFuYWdlci5qYXZh) | `56.57% <0.00%> (-1.27%)` | :arrow_down: |
   | [...d/text/distsql/ral/common/hint/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/15234/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi9oaW50L0hpbnRTb3VyY2VUeXBlLmphdmE=) | `0.00% <0.00%> (-42.86%)` | :arrow_down: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/15234?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/15234?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [8a50d17...12d3c90](https://codecov.io/gh/apache/shardingsphere/pull/15234?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?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] strongduanmu commented on a change in pull request #15234: Adjust get single table data source name mapping.

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #15234:
URL: https://github.com/apache/shardingsphere/pull/15234#discussion_r797459591



##########
File path: shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
##########
@@ -251,9 +251,7 @@ public void alterSchema(final String schemaName, final ShardingSphereSchema sche
      */
     public void alterSchema(final String schemaName, final TableMetaData changedTableMetaData, final String deletedTable) {
         ShardingSphereMetaData metaData = metaDataContexts.getMetaData(schemaName);
-        if (!containsInDataNodeContainedRule(changedTableMetaData.getName(), metaData)) {
-            metaData.getRuleMetaData().findRules(MutableDataNodeRule.class).forEach(each -> each.put(changedTableMetaData.getName(), each.getDataSourceNames().iterator().next()));
-        }
+        singleTableDataSourceMappingRelation(metaData, changedTableMetaData);

Review comment:
       Can we use another meaningful method name? Just like 'alterSingleTableDataNodes'?

##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/MutableDataNodeRule.java
##########
@@ -42,9 +43,10 @@
     void remove(String tableName);
     
     /**
-     * Get data source names.
+     * Find single data node by table name.
      *
-     * @return Get data source names
+     * @param tableName table name
+     * @return single table data node
      */
-    Collection<String> getDataSourceNames();
+    Optional<DataNode> findSingleTableDataNodeByTableName(String tableName);

Review comment:
       @zjcnb Why not change this method to findSingleTableDataNode directly?




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