Class Granularity

    • Constructor Detail

      • Granularity

        public Granularity()
    • Method Detail

      • mergeGranularities

        public static Granularity mergeGranularities​(List<Granularity> toMerge)
        simple merge strategy on query granularity that checks if all are equal or else returns null. this can be improved in future but is good enough for most use-cases.
      • granularitiesFinerThan

        public static List<Granularity> granularitiesFinerThan​(Granularity gran0)
        Returns a list of standard granularities that are equal to, or finer than, a provided granularity. ALL will not be returned unless the provided granularity is ALL. NONE will never be returned, even if the provided granularity is NONE. This is because the main usage of this function in production is segment allocation, and we do not wish to generate NONE-granular segments.
      • getFormatter

        public abstract org.joda.time.format.DateTimeFormatter getFormatter​(Granularity.Formatter type)
      • increment

        public abstract long increment​(long time)
      • increment

        public abstract org.joda.time.DateTime increment​(org.joda.time.DateTime time)
      • bucketStart

        public abstract long bucketStart​(long time)
      • bucketStart

        public abstract org.joda.time.DateTime bucketStart​(org.joda.time.DateTime time)
      • isAligned

        public abstract boolean isAligned​(org.joda.time.Interval interval)
        Return true only if the time chunks populated by this granularity includes the given interval time chunk. The interval must fit exactly into the scheme of the granularity for this to return true
      • getTimeZone

        public org.joda.time.DateTimeZone getTimeZone()
      • bucketEnd

        public org.joda.time.DateTime bucketEnd​(org.joda.time.DateTime time)
      • toDateTime

        public org.joda.time.DateTime toDateTime​(long offset)
      • toDate

        public org.joda.time.DateTime toDate​(String filePath)
      • toPath

        public final String toPath​(org.joda.time.DateTime time)
      • bucket

        public final org.joda.time.Interval bucket​(org.joda.time.DateTime t)
        Return a granularity-sized Interval containing a particular DateTime.
      • isFinerThan

        public boolean isFinerThan​(Granularity g)
        Decides whether this granularity is finer than the other granularity
        Returns:
        true if this Granularity is finer than the passed one
      • getIterable

        public Iterable<org.joda.time.Interval> getIterable​(org.joda.time.Interval input)
        Return an iterable of granular buckets that overlap a particular interval. In cases where the number of granular buckets is very large, the Iterable returned by this method will take an excessive amount of time to compute, and materializing it into a collection will take an excessive amount of memory. For example, this happens in the extreme case of an input interval of Intervals.ETERNITY and any granularity other than Granularities.ALL, as well as cases like an input interval of ten years with Granularities.SECOND. To avoid issues stemming from large numbers of buckets, this method should be avoided, and code that uses this method should be rewritten to use some other approach. For example: rather than computing all possible buckets in a wide time range, only process buckets related to actual data points that appear.