mcvsubbu commented on a change in pull request #5324:
URL: https://github.com/apache/incubator-pinot/pull/5324#discussion_r420253436
##########
File path:
pinot-core/src/main/java/org/apache/pinot/core/data/function/DateTimeFunctions.java
##########
@@ -35,9 +53,127 @@ static Long toEpochHours(Long millis) {
}
/**
- * Convert epoch millis to epoch minutes, bucketed by given bucket
granularity
+ * Convert epoch millis to epoch days
+ */
+ static Long toEpochDays(Long millis) {
+ return TimeUnit.MILLISECONDS.toDays(millis);
+ }
+
+ /**
+ * Convert epoch millis to epoch seconds, round to nearest rounding bucket
+ */
+ static Long toEpochSecondsRounded(Long millis, String roundingValue) {
+ int roundToNearest = Integer.parseInt(roundingValue);
+ return (TimeUnit.MILLISECONDS.toSeconds(millis) / roundToNearest) *
roundToNearest;
+ }
+
+ /**
+ * Convert epoch millis to epoch minutes, round to nearest rounding bucket
+ */
+ static Long toEpochMinutesRounded(Long millis, String roundingValue) {
+ int roundToNearest = Integer.parseInt(roundingValue);
+ return (TimeUnit.MILLISECONDS.toMinutes(millis) / roundToNearest) *
roundToNearest;
+ }
+
+ /**
+ * Convert epoch millis to epoch hours, round to nearest rounding bucket
+ */
+ static Long toEpochHoursRounded(Long millis, String roundingValue) {
+ int roundToNearest = Integer.parseInt(roundingValue);
+ return (TimeUnit.MILLISECONDS.toHours(millis) / roundToNearest) *
roundToNearest;
+ }
+
+ /**
+ * Convert epoch millis to epoch days, round to nearest rounding bucket
+ */
+ static Long toEpochDaysRounded(Long millis, String roundingValue) {
+ int roundToNearest = Integer.parseInt(roundingValue);
+ return (TimeUnit.MILLISECONDS.toDays(millis) / roundToNearest) *
roundToNearest;
+ }
+
+ // TODO: toEpochXXXBucket methods are only needed to convert from
TimeFieldSpec to DateTimeFieldSpec.
Review comment:
It will be nice if you also add here
(1) an example of the use case in time-field-spec that needs bucketing in
order to be backward compatible.
(2) A comment that use of these bucket functions is discouraged unless you
know what you are doing (e.g. 5-minutes-since-epoch does not make sense to
someone looking at the timestamp, or writing queries. instead,
Millis-since-epoch rounded to 5 minutes makes a lot more sense).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]