sandynz commented on issue #13009:
URL: 
https://github.com/apache/shardingsphere/issues/13009#issuecomment-942201335


   Hi @linghengqian , thanks for your feedback.
   
   ```
           for (int i = firstPartition; i <= lastPartition; i++) {
               for (String each : availableTargetNames) {
                   if (each.endsWith(String.valueOf(i))) {
                       result.add(each);
                   }
   ```
   looks `each.endsWith(String.valueOf(i))` might cause issue.
   
   I changed `AutoIntervalShardingAlgorithmTest.java` to do a test:
   ```
       @Before
       public void setup() {
           shardingAlgorithm = new AutoIntervalShardingAlgorithm();
           shardingAlgorithm.getProps().setProperty("datetime-lower", 
"2020-01-01 00:00:00");
           shardingAlgorithm.getProps().setProperty("datetime-upper", 
"2020-01-01 00:00:24");
           shardingAlgorithm.getProps().setProperty("sharding-seconds", "2");
           shardingAlgorithm.init();
       }
   
       
       @Test
       public void assertRangeDoShardingWithPartRange() {
           List<String> availableTargetNames = Arrays.asList("t_order_0", 
"t_order_1", "t_order_2", "t_order_3", "t_order_4");
           availableTargetNames = new ArrayList<>();
           for (int i = 0; i <= 12; i++) {
               availableTargetNames.add("t_order_" + i);
           }
           Collection<String> actual = 
shardingAlgorithm.doSharding(availableTargetNames, new 
RangeShardingValue<>("t_order", "create_time", Range.closed("2020-01-01 
00:00:00", "2020-01-01 00:00:10")));
           ...
       }
   ```
   
   `actual`.size() should be `6`, but it's `9`. `actual` content is:
   ```
   0 = "t_order_0"
   1 = "t_order_10"
   2 = "t_order_1"
   3 = "t_order_11"
   4 = "t_order_2"
   5 = "t_order_12"
   6 = "t_order_3"
   7 = "t_order_4"
   8 = "t_order_5"
   ```
   `t_order_10`, `t_order_11`, `t_order_12` should not be included.
   
   Hi @strongduanmu Would you help to verify 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: [email protected]

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


Reply via email to