shuturmurgh commented on code in PR #18486:
URL: https://github.com/apache/pinot/pull/18486#discussion_r4502312887
##########
pinot-common/src/main/java/org/apache/pinot/common/utils/RetentionUtils.java:
##########
@@ -69,4 +109,43 @@ public static boolean isPurgeable(String tableNameWithType,
SegmentZKMetadata se
}
return false;
}
+
+ /// Parses {@link
SegmentsValidationAndRetentionConfig#getRetentionTimeUnit()} and
+ /// {@link SegmentsValidationAndRetentionConfig#getRetentionTimeValue()}
into table data retention duration in
+ /// milliseconds (same interpretation as controller time-based retention).
+ ///
+ /// @return millis, or empty if unset or not parseable
+ public static OptionalLong parseTableDataRetentionMillis(
+ @Nullable SegmentsValidationAndRetentionConfig validationConfig) {
+ if (validationConfig == null) {
+ return OptionalLong.empty();
+ }
+ String retentionTimeUnit = validationConfig.getRetentionTimeUnit();
+ String retentionTimeValue = validationConfig.getRetentionTimeValue();
+ if (StringUtils.isEmpty(retentionTimeUnit) ||
StringUtils.isEmpty(retentionTimeValue)) {
+ return OptionalLong.empty();
+ }
+ try {
+ return
OptionalLong.of(TimeUnit.valueOf(retentionTimeUnit.toUpperCase(Locale.ROOT))
+ .toMillis(Long.parseLong(retentionTimeValue)));
+ } catch (Exception e) {
+ LOGGER.debug("Failed to parse table data retention: unit='{}'
value='{}'", retentionTimeUnit, retentionTimeValue,
+ e);
+ return OptionalLong.empty();
+ }
+ }
+
+ /// Returns segment end time in epoch millis from on-disk {@link
SegmentMetadata} for retention comparison, using
+ /// {@link SegmentMetadata#getTimeUnit()} and {@link
SegmentMetadata#getEndTime()} (same raw fields minion task
+ /// executors pass when configuring generation from segment files). When
`timeUnit` is non-null and raw end time is
+ /// not {@link Long#MIN_VALUE}, returns `timeUnit.toMillis(endTime)`;
otherwise returns the raw end time (typically
+ /// `Long.MIN_VALUE` when unset).
+ public static long getSegmentMetadataEndTimeMillis(SegmentMetadata
segmentMetadata) {
Review Comment:
Done in e167b86. I removed the getter tests, including the ones that
verified `getTimeInterval()` is never called. The conversion is now covered
through `isPurgeable` outcomes:
- millisecond end time at the boundary and 1 ms past it
- `DAYS` end time converted around the 7-day window
- invalid end time
- no time metadata (null unit, `Long.MIN_VALUE` end time)
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]