wuzhenhua01 commented on code in PR #10220:
URL: https://github.com/apache/hudi/pull/10220#discussion_r1426230891
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/util/StreamerUtil.java:
##########
@@ -378,34 +376,30 @@ public static Option<HoodieTableConfig>
getTableConfig(String basePath, org.apac
* Returns the median instant time between the given two instant time.
*/
public static Option<String> medianInstantTime(String highVal, String
lowVal) {
- try {
- long high =
HoodieActiveTimeline.parseDateFromInstantTime(highVal).getTime();
- long low =
HoodieActiveTimeline.parseDateFromInstantTime(lowVal).getTime();
- ValidationUtils.checkArgument(high > low,
- "Instant [" + highVal + "] should have newer timestamp than instant
[" + lowVal + "]");
- long median = low + (high - low) / 2;
- final String instantTime = HoodieActiveTimeline.formatDate(new
Date(median));
- if (HoodieTimeline.compareTimestamps(lowVal,
HoodieTimeline.GREATER_THAN_OR_EQUALS, instantTime)
- || HoodieTimeline.compareTimestamps(highVal,
HoodieTimeline.LESSER_THAN_OR_EQUALS, instantTime)) {
- return Option.empty();
- }
- return Option.of(instantTime);
- } catch (ParseException e) {
- throw new HoodieException("Get median instant time with interval [" +
lowVal + ", " + highVal + "] error", e);
+ long high = HoodieActiveTimeline.parseDateFromInstantTimeSafely(highVal)
+ .orElseThrow(() -> new HoodieException("Get instant time diff with
interval [" + highVal + "] error")).getTime();
+ long low = HoodieActiveTimeline.parseDateFromInstantTimeSafely(lowVal)
Review Comment:
i mean the method `orElseThrow` is fordefensive programming. sure, we can
repeat the provided operation procedure that can reproduce this exception
--
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]