zhangOranges opened a new issue, #29005:
URL: https://github.com/apache/shardingsphere/issues/29005

   Version: 5.1.0
   
Class:org.apache.shardingsphere.sharding.route.engine.type.unicast.ShardingUnicastRoutingEngine
   `@Override
       public RouteContext route(final ShardingRule shardingRule) {
           RouteContext result = new RouteContext();
           String dataSourceName = 
getRandomDataSourceName(shardingRule.getDataSourceNames());
           RouteMapper dataSourceMapper = new RouteMapper(dataSourceName, 
dataSourceName);
           if (shardingRule.isAllBroadcastTables(logicTables)) {
               List<RouteMapper> tableMappers = new 
ArrayList<>(logicTables.size());
               for (String each : logicTables) {
                   tableMappers.add(new RouteMapper(each, each));
               }
               result.getRouteUnits().add(new RouteUnit(dataSourceMapper, 
tableMappers));
           } else if (logicTables.isEmpty()) {
               result.getRouteUnits().add(new RouteUnit(dataSourceMapper, 
Collections.emptyList()));
           } else if (1 == logicTables.size()) {
               String logicTableName = logicTables.iterator().next();
               if (!shardingRule.findTableRule(logicTableName).isPresent()) {
                   result.getRouteUnits().add(new RouteUnit(dataSourceMapper, 
Collections.emptyList()));
                   return result;
               }
               DataNode dataNode = shardingRule.getDataNode(logicTableName);
               result.getRouteUnits().add(new RouteUnit(new 
RouteMapper(dataNode.getDataSourceName(), dataNode.getDataSourceName()),
                       Collections.singletonList(new 
RouteMapper(logicTableName, dataNode.getTableName()))));
           } else {
               routeWithMultipleTables(result, shardingRule);
           }
           return result;
       }`
   shardingRule.getDataNode method 
   Class:org.apache.shardingsphere.sharding.rule.ShardingRule
   `    public DataNode getDataNode(final String logicTableName) {
           TableRule tableRule = getTableRule(logicTableName);
           return tableRule.getActualDataNodes().get(0);
       }`
   Directly get (0) here
   If I choose one, the results of my query will not be correct. Should I 
return all the actual nodes here?
   


-- 
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: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to