sandynz commented on code in PR #28356:
URL: https://github.com/apache/shardingsphere/pull/28356#discussion_r1315314770
##########
kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/common/job/progress/InventoryIncrementalJobItemProgressTest.java:
##########
@@ -76,6 +79,24 @@ void assertGetIncrementalDataLatestActiveTimeMillis() {
assertThat(getJobItemProgress(ConfigurationFileUtils.readFile("job-progress-all-finished.yaml")).getIncremental().getIncrementalLatestActiveTimeMillis(),
is(50L));
}
+ @Test
+ void assertGetProgressesCorrectly() {
+ Map<String, InventoryTaskProgress> progresses = new HashMap<>();
+ progresses.put("ds.order_item#0", new InventoryTaskProgress(new
IntegerPrimaryKeyPosition(1, 100)));
+ progresses.put("ds.order_item#1", new InventoryTaskProgress(new
IntegerPrimaryKeyPosition(100, 200)));
+ progresses.put("ds.order#0", new InventoryTaskProgress(new
FinishedPosition()));
+ progresses.put("ds.test_order#0", new InventoryTaskProgress(new
FinishedPosition()));
+ JobItemInventoryTasksProgress progress = new
JobItemInventoryTasksProgress(progresses);
+ Map<String, IngestPosition> orderPosition =
progress.getInventoryPosition("order");
+ assertThat(orderPosition.size(), is(1));
+ assertTrue(orderPosition.containsKey("ds.order#0"));
+ Map<String, IngestPosition> testOrderPosition =
progress.getInventoryPosition("test_order");
+ assertThat(testOrderPosition.size(), is(1));
+ assertTrue(testOrderPosition.containsKey("ds.test_order#0"));
+ Map<String, IngestPosition> orderItemPosition =
progress.getInventoryPosition("order_item");
+ assertThat(orderItemPosition.size(), is(2));
Review Comment:
Could we assert position but not only size?
##########
kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/progress/JobItemInventoryTasksProgress.java:
##########
@@ -43,7 +43,7 @@ public final class JobItemInventoryTasksProgress {
* @return inventory position
*/
public Map<String, IngestPosition> getInventoryPosition(final String
tableName) {
- Pattern pattern = Pattern.compile(String.format("%s(#\\d+)?",
tableName));
+ Pattern pattern = Pattern.compile(String.format("\\.%s#(\\d+)?",
tableName));
Review Comment:
Is `#` always existing?
From old code:
```
private String generateTaskId(final InventoryDumperConfiguration
inventoryDumperConfig) {
String result = String.format("%s.%s",
inventoryDumperConfig.getDataSourceName(),
inventoryDumperConfig.getActualTableName());
return null == inventoryDumperConfig.getShardingItem() ? result :
result + "#" + inventoryDumperConfig.getShardingItem();
}
```
--
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]