Interface TimeFrameSet.Builder

Enclosing class:

public static interface TimeFrameSet.Builder
Builds a collection of time frames.
  • Method Details

    • build

      TimeFrameSet build()
      Creates a TimeFrameSet.
    • addCore

      Defines a core time frame.
    • addQuotient

      TimeFrameSet.Builder addQuotient(String name, String minorName, String majorName)
      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

      TimeFrameSet.Builder addMultiple(String name, Number count, String baseName)
      Defines a time frame that consists of count instances of a base frame.
    • addDivision

      TimeFrameSet.Builder addDivision(String name, Number count, String baseName)
      Defines a time frame such that each base frame consists of count instances of the new frame.
    • addRollup

      TimeFrameSet.Builder addRollup(String fromName, String toName)
      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 to HOUR). Only use this method for frames that are not multiples (such as DAY to MONTH).

      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 to YEAR, 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 and ISOYEAR are designed so that ISOWEEK can roll up to ISOYEAR. Every ISOYEAR and ISOWEEK start on a Monday, so they are aligned. An ISOYEAR consists of either 52 or 53 ISOWEEK instances, but the variable multiple is not a problem; the alignment ensures that rollup is valid.

    • addAll

      TimeFrameSet.Builder addAll(TimeFrameSet timeFrameSet)
      Adds all time frames in timeFrameSet to this Builder.
    • withEpoch

      Replaces the epoch of the most recently added frame.
    • addAlias

      TimeFrameSet.Builder addAlias(String name, String originalName)
      Defines an alias for an existing frame.

      For example, add("Y", "YEAR") adds "Y" as an alias for the built-in frame YEAR.

      name - The alias
      originalName - Name of the existing frame