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 2020/06/17 02:41:16 UTC

[GitHub] [shardingsphere] beiwangnull opened a new pull request #6085: optimize route table where database and table shared columns

beiwangnull opened a new pull request #6085:
URL: https://github.com/apache/shardingsphere/pull/6085


   Fixes #ISSUSE_ID.
   #3366 
   Changes proposed in this pull request:
   -
   -
   -
   


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



[GitHub] [shardingsphere] beiwangnull closed pull request #6085: optimize route table where database and table shared columns

Posted by GitBox <gi...@apache.org>.
beiwangnull closed pull request #6085:
URL: https://github.com/apache/shardingsphere/pull/6085


   


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



[GitHub] [shardingsphere] beiwangnull closed pull request #6085: optimize route table where database and table shared columns

Posted by GitBox <gi...@apache.org>.
beiwangnull closed pull request #6085:
URL: https://github.com/apache/shardingsphere/pull/6085


   


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



[GitHub] [shardingsphere] beiwangnull commented on pull request #6085: optimize route table where database and table shared columns

Posted by GitBox <gi...@apache.org>.
beiwangnull commented on pull request #6085:
URL: https://github.com/apache/shardingsphere/pull/6085#issuecomment-664859777


   RangeValue unable to filter the corresponding database,only the determined value can be adapted.


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



[GitHub] [shardingsphere] KomachiSion commented on a change in pull request #6085: optimize route table where database and table shared columns

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngine.java
##########
@@ -191,8 +193,38 @@ private boolean isGettingShardingValuesFromHint(final ShardingStrategy shardingS
     private Collection<DataNode> route0(final ShardingRule shardingRule, final TableRule tableRule, final List<RouteValue> databaseShardingValues, final List<RouteValue> tableShardingValues) {
         Collection<String> routedDataSources = routeDataSources(shardingRule, tableRule, databaseShardingValues);
         Collection<DataNode> result = new LinkedList<>();
+        List<RouteValue> copiedTableShardingValues = tableShardingValues;
         for (String each : routedDataSources) {
-            result.addAll(routeTables(shardingRule, tableRule, each, tableShardingValues));
+
+            if (null != tableRule.getDatabaseShardingStrategy() && null != tableRule.getTableShardingStrategy()
+                && 0 != tableRule.getDatabaseShardingStrategy().getShardingColumns().size() && 0 != tableRule.getTableShardingStrategy().getShardingColumns().size()
+                && databaseShardingValues.size() > 0 && tableShardingValues.size() > 0
+                && tableRule.getDatabaseShardingStrategy().getShardingColumns().size() == tableRule.getTableShardingStrategy().getShardingColumns().size()
+                && tableRule.getDatabaseShardingStrategy().getShardingColumns().containsAll(tableRule.getTableShardingStrategy().getShardingColumns())) {
+                Collection<Object> relateValueList = Lists.newArrayList();
+
+                ListRouteValue tableRouteValue = (ListRouteValue) tableShardingValues.get(0);

Review comment:
       How can you confirm that the first sharding value is list not range? And what's the result if  there are more than list sharding values?

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngine.java
##########
@@ -191,8 +193,38 @@ private boolean isGettingShardingValuesFromHint(final ShardingStrategy shardingS
     private Collection<DataNode> route0(final ShardingRule shardingRule, final TableRule tableRule, final List<RouteValue> databaseShardingValues, final List<RouteValue> tableShardingValues) {
         Collection<String> routedDataSources = routeDataSources(shardingRule, tableRule, databaseShardingValues);
         Collection<DataNode> result = new LinkedList<>();
+        List<RouteValue> copiedTableShardingValues = tableShardingValues;
         for (String each : routedDataSources) {
-            result.addAll(routeTables(shardingRule, tableRule, each, tableShardingValues));
+
+            if (null != tableRule.getDatabaseShardingStrategy() && null != tableRule.getTableShardingStrategy()
+                && 0 != tableRule.getDatabaseShardingStrategy().getShardingColumns().size() && 0 != tableRule.getTableShardingStrategy().getShardingColumns().size()
+                && databaseShardingValues.size() > 0 && tableShardingValues.size() > 0
+                && tableRule.getDatabaseShardingStrategy().getShardingColumns().size() == tableRule.getTableShardingStrategy().getShardingColumns().size()
+                && tableRule.getDatabaseShardingStrategy().getShardingColumns().containsAll(tableRule.getTableShardingStrategy().getShardingColumns())) {
+                Collection<Object> relateValueList = Lists.newArrayList();
+
+                ListRouteValue tableRouteValue = (ListRouteValue) tableShardingValues.get(0);
+                Collection<Object> tablueRouteValues = tableRouteValue.getValues();
+
+                for (Object eachRouteValues : tablueRouteValues) {
+                    RouteValue routeValue = new ListRouteValue(tableRouteValue.getColumnName(), tableRouteValue.getTableName(), Lists.newArrayList(eachRouteValues));
+
+                    Collection<String> reRouteDbRoute = routeDataSources(shardingRule, tableRule, Lists.newArrayList(routeValue));

Review comment:
       There will route datasource second time for each value. It may cost much time.




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



[GitHub] [shardingsphere] terrymanu commented on pull request #6085: optimize route table where database and table shared columns

Posted by GitBox <gi...@apache.org>.
terrymanu commented on pull request #6085:
URL: https://github.com/apache/shardingsphere/pull/6085#issuecomment-645134102


   Please fix CI first


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



[GitHub] [shardingsphere] beiwangnull commented on a change in pull request #6085: optimize route table where database and table shared columns

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



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngine.java
##########
@@ -191,8 +193,38 @@ private boolean isGettingShardingValuesFromHint(final ShardingStrategy shardingS
     private Collection<DataNode> route0(final ShardingRule shardingRule, final TableRule tableRule, final List<RouteValue> databaseShardingValues, final List<RouteValue> tableShardingValues) {
         Collection<String> routedDataSources = routeDataSources(shardingRule, tableRule, databaseShardingValues);
         Collection<DataNode> result = new LinkedList<>();
+        List<RouteValue> copiedTableShardingValues = tableShardingValues;
         for (String each : routedDataSources) {
-            result.addAll(routeTables(shardingRule, tableRule, each, tableShardingValues));
+
+            if (null != tableRule.getDatabaseShardingStrategy() && null != tableRule.getTableShardingStrategy()
+                && 0 != tableRule.getDatabaseShardingStrategy().getShardingColumns().size() && 0 != tableRule.getTableShardingStrategy().getShardingColumns().size()
+                && databaseShardingValues.size() > 0 && tableShardingValues.size() > 0
+                && tableRule.getDatabaseShardingStrategy().getShardingColumns().size() == tableRule.getTableShardingStrategy().getShardingColumns().size()
+                && tableRule.getDatabaseShardingStrategy().getShardingColumns().containsAll(tableRule.getTableShardingStrategy().getShardingColumns())) {
+                Collection<Object> relateValueList = Lists.newArrayList();
+
+                ListRouteValue tableRouteValue = (ListRouteValue) tableShardingValues.get(0);

Review comment:
       1、 I didn't expect that RangeValue. 

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngine.java
##########
@@ -191,8 +193,38 @@ private boolean isGettingShardingValuesFromHint(final ShardingStrategy shardingS
     private Collection<DataNode> route0(final ShardingRule shardingRule, final TableRule tableRule, final List<RouteValue> databaseShardingValues, final List<RouteValue> tableShardingValues) {
         Collection<String> routedDataSources = routeDataSources(shardingRule, tableRule, databaseShardingValues);
         Collection<DataNode> result = new LinkedList<>();
+        List<RouteValue> copiedTableShardingValues = tableShardingValues;
         for (String each : routedDataSources) {
-            result.addAll(routeTables(shardingRule, tableRule, each, tableShardingValues));
+
+            if (null != tableRule.getDatabaseShardingStrategy() && null != tableRule.getTableShardingStrategy()
+                && 0 != tableRule.getDatabaseShardingStrategy().getShardingColumns().size() && 0 != tableRule.getTableShardingStrategy().getShardingColumns().size()
+                && databaseShardingValues.size() > 0 && tableShardingValues.size() > 0
+                && tableRule.getDatabaseShardingStrategy().getShardingColumns().size() == tableRule.getTableShardingStrategy().getShardingColumns().size()
+                && tableRule.getDatabaseShardingStrategy().getShardingColumns().containsAll(tableRule.getTableShardingStrategy().getShardingColumns())) {
+                Collection<Object> relateValueList = Lists.newArrayList();
+
+                ListRouteValue tableRouteValue = (ListRouteValue) tableShardingValues.get(0);

Review comment:
       2、just care algorithms

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngine.java
##########
@@ -191,8 +193,38 @@ private boolean isGettingShardingValuesFromHint(final ShardingStrategy shardingS
     private Collection<DataNode> route0(final ShardingRule shardingRule, final TableRule tableRule, final List<RouteValue> databaseShardingValues, final List<RouteValue> tableShardingValues) {
         Collection<String> routedDataSources = routeDataSources(shardingRule, tableRule, databaseShardingValues);
         Collection<DataNode> result = new LinkedList<>();
+        List<RouteValue> copiedTableShardingValues = tableShardingValues;
         for (String each : routedDataSources) {
-            result.addAll(routeTables(shardingRule, tableRule, each, tableShardingValues));
+
+            if (null != tableRule.getDatabaseShardingStrategy() && null != tableRule.getTableShardingStrategy()
+                && 0 != tableRule.getDatabaseShardingStrategy().getShardingColumns().size() && 0 != tableRule.getTableShardingStrategy().getShardingColumns().size()
+                && databaseShardingValues.size() > 0 && tableShardingValues.size() > 0
+                && tableRule.getDatabaseShardingStrategy().getShardingColumns().size() == tableRule.getTableShardingStrategy().getShardingColumns().size()
+                && tableRule.getDatabaseShardingStrategy().getShardingColumns().containsAll(tableRule.getTableShardingStrategy().getShardingColumns())) {
+                Collection<Object> relateValueList = Lists.newArrayList();
+
+                ListRouteValue tableRouteValue = (ListRouteValue) tableShardingValues.get(0);
+                Collection<Object> tablueRouteValues = tableRouteValue.getValues();
+
+                for (Object eachRouteValues : tablueRouteValues) {
+                    RouteValue routeValue = new ListRouteValue(tableRouteValue.getColumnName(), tableRouteValue.getTableName(), Lists.newArrayList(eachRouteValues));
+
+                    Collection<String> reRouteDbRoute = routeDataSources(shardingRule, tableRule, Lists.newArrayList(routeValue));

Review comment:
       you are right




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