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 2021/09/22 11:11:14 UTC
[GitHub] [shardingsphere] tuichenchuxin opened a new pull request #12625: Fix IntervalShardingAlgorithm.
tuichenchuxin opened a new pull request #12625:
URL: https://github.com/apache/shardingsphere/pull/12625
Fixes #12597 .
Changes proposed in this pull request:
- Interval Sharding algorithm not use `datetime-interval-amount`, fix it.
- Add test case.
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] codecov-commenter edited a comment on pull request #12625: Fix IntervalShardingAlgorithm.
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #12625:
URL: https://github.com/apache/shardingsphere/pull/12625#issuecomment-925046127
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#12625](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (4724b07) into [master](https://codecov.io/gh/apache/shardingsphere/commit/65c9414bfdac5bd87fc6638dbf85b6ee53ae92b5?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (65c9414) will **decrease** coverage by `0.00%`.
> The diff coverage is `90.90%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/12625/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #12625 +/- ##
============================================
- Coverage 63.38% 63.38% -0.01%
- Complexity 1327 1328 +1
============================================
Files 2440 2440
Lines 37009 37039 +30
Branches 6405 6403 -2
============================================
+ Hits 23459 23478 +19
- Misses 11645 11668 +23
+ Partials 1905 1893 -12
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...m/sharding/datetime/IntervalShardingAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvYWxnb3JpdGhtL3NoYXJkaW5nL2RhdGV0aW1lL0ludGVydmFsU2hhcmRpbmdBbGdvcml0aG0uamF2YQ==) | `86.04% <90.90%> (+1.60%)` | :arrow_up: |
| [...ere/proxy/frontend/executor/UserExecutorGroup.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvZnJvbnRlbmQvZXhlY3V0b3IvVXNlckV4ZWN1dG9yR3JvdXAuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...d/text/distsql/ral/common/hint/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi9oaW50L0hpbnRTb3VyY2VUeXBlLmphdmE=) | `0.00% <0.00%> (-42.86%)` | :arrow_down: |
| [...gsphere/mode/metadata/MetaDataContextsBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbWV0YWRhdGEvTWV0YURhdGFDb250ZXh0c0J1aWxkZXIuamF2YQ==) | `70.00% <0.00%> (-25.46%)` | :arrow_down: |
| [.../apache/shardingsphere/shadow/rule/ShadowRule.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhZG93L3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaGFkb3cvcnVsZS9TaGFkb3dSdWxlLmphdmE=) | `70.27% <0.00%> (-6.21%)` | :arrow_down: |
| [...shardingsphere/mode/metadata/MetaDataContexts.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbWV0YWRhdGEvTWV0YURhdGFDb250ZXh0cy5qYXZh) | `65.00% <0.00%> (-3.43%)` | :arrow_down: |
| [...r/jdbc/core/statement/ShardingSphereStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvc3RhdGVtZW50L1NoYXJkaW5nU3BoZXJlU3RhdGVtZW50LmphdmE=) | `66.83% <0.00%> (-0.17%)` | :arrow_down: |
| [.../proxy/backend/communication/ProxySQLExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9jb21tdW5pY2F0aW9uL1Byb3h5U1FMRXhlY3V0b3IuamF2YQ==) | `31.66% <0.00%> (ø)` | |
| [...ra/config/properties/ConfigurationPropertyKey.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9jb25maWcvcHJvcGVydGllcy9Db25maWd1cmF0aW9uUHJvcGVydHlLZXkuamF2YQ==) | `100.00% <0.00%> (ø)` | |
| [...ore/statement/ShardingSpherePreparedStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2NvcmUvc3RhdGVtZW50L1NoYXJkaW5nU3BoZXJlUHJlcGFyZWRTdGF0ZW1lbnQuamF2YQ==) | `75.00% <0.00%> (ø)` | |
| ... and [47 more](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [65c9414...4724b07](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #12625: Fix IntervalShardingAlgorithm.
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #12625:
URL: https://github.com/apache/shardingsphere/pull/12625#discussion_r714528396
##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
##########
@@ -120,30 +122,37 @@ private ChronoUnit getStepUnit(final String stepUnit) {
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Comparable<?>> shardingValue) {
- String tableNameSuffix = parseDateTime(shardingValue.getValue().toString()).format(tableSuffixPattern);
- return availableTargetNames.stream()
- .filter(each -> each.endsWith(tableNameSuffix))
- .findFirst().orElse(null);
+ return doSharding(availableTargetNames, Range.singleton(shardingValue.getValue())).stream().findFirst().orElse(null);
}
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final RangeShardingValue<Comparable<?>> shardingValue) {
- boolean hasStartTime = shardingValue.getValueRange().hasLowerBound();
- boolean hasEndTime = shardingValue.getValueRange().hasUpperBound();
- if (!hasStartTime && !hasEndTime) {
- return availableTargetNames;
- }
- LocalDateTime startTime = hasStartTime ? parseDateTime(shardingValue.getValueRange().lowerEndpoint().toString()) : dateTimeLower;
- LocalDateTime endTime = hasEndTime ? parseDateTime(shardingValue.getValueRange().upperEndpoint().toString()) : dateTimeUpper;
- LocalDateTime calculateTime = startTime;
+ return doSharding(availableTargetNames, shardingValue.getValueRange());
+ }
+
+ private Collection<String> doSharding(final Collection<String> availableTargetNames, final Range<Comparable<?>> range) {
Set<String> result = new HashSet<>();
- while (!calculateTime.isAfter(endTime) || calculateTime.format(tableSuffixPattern).equals(endTime.format(tableSuffixPattern))) {
- result.addAll(getMatchedTables(calculateTime, availableTargetNames));
+ LocalDateTime calculateTime = dateTimeLower;
+ while (!calculateTime.isAfter(dateTimeUpper)) {
+ if (hasIntersection(Range.closedOpen(calculateTime, calculateTime.plus(stepAmount, stepUnit)), range)) {
+ result.addAll(getMatchedTables(calculateTime, availableTargetNames));
+ }
calculateTime = calculateTime.plus(stepAmount, stepUnit);
}
return result;
}
+ private boolean hasIntersection(final Range<LocalDateTime> calculateRange, final Range<Comparable<?>> range) {
Review comment:
@tuichenchuxin Can we replace this logic with guava range intersection?
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] codecov-commenter commented on pull request #12625: Fix IntervalShardingAlgorithm.
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #12625:
URL: https://github.com/apache/shardingsphere/pull/12625#issuecomment-925046127
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#12625](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (eb04461) into [master](https://codecov.io/gh/apache/shardingsphere/commit/65c9414bfdac5bd87fc6638dbf85b6ee53ae92b5?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (65c9414) will **decrease** coverage by `0.05%`.
> The diff coverage is `83.33%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/12625/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #12625 +/- ##
============================================
- Coverage 63.38% 63.33% -0.06%
- Complexity 1327 1328 +1
============================================
Files 2440 2439 -1
Lines 37009 37056 +47
Branches 6405 6419 +14
============================================
+ Hits 23459 23470 +11
- Misses 11645 11677 +32
- Partials 1905 1909 +4
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...m/sharding/datetime/IntervalShardingAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvYWxnb3JpdGhtL3NoYXJkaW5nL2RhdGV0aW1lL0ludGVydmFsU2hhcmRpbmdBbGdvcml0aG0uamF2YQ==) | `82.14% <83.33%> (-2.31%)` | :arrow_down: |
| [...ere/proxy/frontend/executor/UserExecutorGroup.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvZnJvbnRlbmQvZXhlY3V0b3IvVXNlckV4ZWN1dG9yR3JvdXAuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [...gsphere/mode/metadata/MetaDataContextsBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbWV0YWRhdGEvTWV0YURhdGFDb250ZXh0c0J1aWxkZXIuamF2YQ==) | `70.00% <0.00%> (-25.46%)` | :arrow_down: |
| [.../apache/shardingsphere/shadow/rule/ShadowRule.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhZG93L3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaGFkb3cvcnVsZS9TaGFkb3dSdWxlLmphdmE=) | `70.27% <0.00%> (-6.21%)` | :arrow_down: |
| [...shardingsphere/mode/metadata/MetaDataContexts.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL21vZGUvbWV0YWRhdGEvTWV0YURhdGFDb250ZXh0cy5qYXZh) | `65.00% <0.00%> (-3.43%)` | :arrow_down: |
| [...ra/config/properties/ConfigurationPropertyKey.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9jb25maWcvcHJvcGVydGllcy9Db25maWd1cmF0aW9uUHJvcGVydHlLZXkuamF2YQ==) | `100.00% <0.00%> (ø)` | |
| [...dingsphere/proxy/frontend/ShardingSphereProxy.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvZnJvbnRlbmQvU2hhcmRpbmdTcGhlcmVQcm94eS5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...here/singletable/route/SingleTableRouteEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXNpbmdsZS10YWJsZS9zaGFyZGluZ3NwaGVyZS1zaW5nbGUtdGFibGUtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2luZ2xldGFibGUvcm91dGUvU2luZ2xlVGFibGVSb3V0ZUVuZ2luZS5qYXZh) | `60.37% <0.00%> (ø)` | |
| [...re/singletable/rule/SingleTableDataNodeLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXNpbmdsZS10YWJsZS9zaGFyZGluZ3NwaGVyZS1zaW5nbGUtdGFibGUtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2luZ2xldGFibGUvcnVsZS9TaW5nbGVUYWJsZURhdGFOb2RlTG9hZGVyLmphdmE=) | `90.47% <0.00%> (ø)` | |
| [...de/manager/memory/MemoryContextManagerBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtbWVtb3J5LW1vZGUvc2hhcmRpbmdzcGhlcmUtbWVtb3J5LW1vZGUtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvbW9kZS9tYW5hZ2VyL21lbW9yeS9NZW1vcnlDb250ZXh0TWFuYWdlckJ1aWxkZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| ... and [31 more](https://codecov.io/gh/apache/shardingsphere/pull/12625/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [65c9414...eb04461](https://codecov.io/gh/apache/shardingsphere/pull/12625?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu merged pull request #12625: Fix IntervalShardingAlgorithm.
Posted by GitBox <gi...@apache.org>.
strongduanmu merged pull request #12625:
URL: https://github.com/apache/shardingsphere/pull/12625
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #12625: Fix IntervalShardingAlgorithm.
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on a change in pull request #12625:
URL: https://github.com/apache/shardingsphere/pull/12625#discussion_r714421917
##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
##########
@@ -135,10 +151,12 @@ public String doSharding(final Collection<String> availableTargetNames, final Pr
}
LocalDateTime startTime = hasStartTime ? parseDateTime(shardingValue.getValueRange().lowerEndpoint().toString()) : dateTimeLower;
LocalDateTime endTime = hasEndTime ? parseDateTime(shardingValue.getValueRange().upperEndpoint().toString()) : dateTimeUpper;
- LocalDateTime calculateTime = startTime;
+ LocalDateTime calculateTime = dateTimeLower;
Set<String> result = new HashSet<>();
- while (!calculateTime.isAfter(endTime) || calculateTime.format(tableSuffixPattern).equals(endTime.format(tableSuffixPattern))) {
- result.addAll(getMatchedTables(calculateTime, availableTargetNames));
+ while (!calculateTime.isAfter(dateTimeUpper)) {
+ if (calculateTime.plus(stepAmount, stepUnit).isAfter(startTime) && !calculateTime.isAfter(endTime)) {
Review comment:
@tuichenchuxin Can we extract this common logic?
##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
##########
@@ -120,10 +121,25 @@ private ChronoUnit getStepUnit(final String stepUnit) {
@Override
public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Comparable<?>> shardingValue) {
- String tableNameSuffix = parseDateTime(shardingValue.getValue().toString()).format(tableSuffixPattern);
- return availableTargetNames.stream()
- .filter(each -> each.endsWith(tableNameSuffix))
- .findFirst().orElse(null);
+ return doSharding(shardingValue).flatMap(suffix -> availableTargetNames.stream()
+ .filter(each -> each.endsWith(suffix))
+ .findFirst()).orElse(null);
+ }
+
+ private Optional<String> doSharding(final PreciseShardingValue<Comparable<?>> shardingValue) {
+ LocalDateTime dateTime = parseDateTime(shardingValue.getValue().toString());
+ if (dateTime.isBefore(dateTimeLower) || !dateTime.isBefore(dateTimeUpper)) {
Review comment:
@tuichenchuxin `isAfter` may be better.
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org