xiaoma20082008 commented on issue #2193: Table doesn't exist when sharding 
value in different datasource with in expression
URL: 
https://github.com/apache/incubator-shardingsphere/issues/2193#issuecomment-519484038
 
 
   
   hello , I have the same problems, when will you solve this issue, and 
publish a release version ?
   I guess the problem may happen at the TableRule class about actualDataNodes 
property.
   I have an 8 shard databases and 64 shard columns. 
   the actualDataNodes string just like this:
   ```
   "ds_${0..8}.tb_${0..63}"
   ```
   Expect actualDataNodes just like this:
   ```
   ds_0-> tb_0, tb_8, tb_16, tb_24, tb_32, tb_40, tb_48, tb_56
   ds_1-> tb_1, tb_9, tb_17, tb_25, tb_33, tb_41, tb_49, tb_57
   ds_2-> tb_2, tb_10, tb_18, tb_26, tb_34, tb_42, tb_50, tb_58
   ds_3-> tb_3, tb_11, tb_19, tb_27, tb_35, tb_43, tb_51, tb_59
   ds_4-> tb_4, tb_12, tb_20, tb_28, tb_36, tb_44, tb_52, tb_60
   ds_5-> tb_5, tb_13, tb_21, tb_29, tb_37, tb_45, tb_53, tb_61
   ds_6-> tb_6, tb_14, tb_22, tb_30, tb_38, tb_46, tb_54, tb_62
   ds_7-> tb_7, tb_15, tb_23, tb_31, tb_39, tb_47, tb_55, tb_63
   ```
   Here is a code for reference only
   ```java
   private Map<String, List<DataNode>> convertDataNodes(List<DataNode> 
dataNodes) {
           LinkedHashMap<String, List<DataNode>> result = new LinkedHashMap<>();
           for (DataNode dataNode : dataNodes) {
               List<DataNode> nodes = result.get(dataNode.getDataSourceName());
               if (nodes == null) {
                   nodes = new ArrayList<>();
                   result.put(dataNode.getDataSourceName(), nodes);
               }
               nodes.add(dataNode);
           }
           final int size = result.size();
           int i = 0;
           for (Map.Entry<String, List<DataNode>> e : result.entrySet()) {
               final List<DataNode> tables = e.getValue();
               final List<DataNode> list   = new ArrayList<>(size);
               // notice here
               for (int j = i; j < tables.size(); j += size) {
                   list.add(tables.get(j));
               }
               e.setValue(list);
               i++;
           }
           return result;
       }
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to