Interface TimeFrameSet.Builder
- Enclosing class:
TimeFrameSet
-
Method Summary
Modifier and TypeMethodDescriptionDefines an alias for an existing frame.addAll
(TimeFrameSet timeFrameSet) Adds all time frames intimeFrameSet
to thisBuilder
.Defines a core time frame.addDivision
(String name, Number count, String baseName) Defines a time frame such that each base frame consists ofcount
instances of the new frame.addMultiple
(String name, Number count, String baseName) Defines a time frame that consists ofcount
instances of a base frame.addQuotient
(String name, String minorName, String majorName) Defines a time frame that is the number of a minor unit within a major frame.Defines a rollup from one frame to another.build()
Creates aTimeFrameSet
.withEpoch
(TimestampString epoch) Replaces the epoch of the most recently added frame.
-
Method Details
-
build
TimeFrameSet build()Creates aTimeFrameSet
. -
addCore
Defines a core time frame. -
addQuotient
Defines a time frame that is the number of a minor unit within a major frame. For example, the "DOY" frame has minor "DAY" and major "YEAR". -
addMultiple
Defines a time frame that consists ofcount
instances of a base frame. -
addDivision
Defines a time frame such that each base frame consists ofcount
instances of the new frame. -
addRollup
Defines a rollup from one frame to another.An explicit rollup is not necessary for frames where one is a multiple of another (such as
MILLISECOND
toHOUR
). Only use this method for frames that are not multiples (such asDAY
toMONTH
).How do we automatically roll up from say, "minute15" to "hour7"? Because we know the following:
- "minute15" and "hour7" are based on the same core frame (seconds);
- "minute15" is 15 * 60 seconds, "hour7" is 7 * 60 * 60 seconds, and the one divides the other;
- They have the same offset, 1970-01-01 00:00:00. (Different offsets would be OK too, as they are a whole multiple apart.)
A month is not a fixed multiple of days, but a rollup is still possible, because the start of a month is always aligned with the start of a day. This means that you can compute a month total by adding up the day totals for all days in that month. This is useful if you have an aggregate table on DAY and you want to answer a query on
MONTH
.There is no rollup from
WEEK
toYEAR
, because of a lack of alignment: a year does not start on the first day of a week, and so you cannot compute the total for, say, the year 2022 by adding the totals for all weeks that fall in 2022.Incidentally,
ISOWEEK
andISOYEAR
are designed so thatISOWEEK
can roll up toISOYEAR
. EveryISOYEAR
andISOWEEK
start on a Monday, so they are aligned. AnISOYEAR
consists of either 52 or 53ISOWEEK
instances, but the variable multiple is not a problem; the alignment ensures that rollup is valid. -
addAll
Adds all time frames intimeFrameSet
to thisBuilder
. -
withEpoch
Replaces the epoch of the most recently added frame. -
addAlias
Defines an alias for an existing frame.For example,
add("Y", "YEAR")
adds "Y" as an alias for the built-in frameYEAR
.- Parameters:
name
- The aliasoriginalName
- Name of the existing frame
-