Class Granularity
java.lang.Object
org.apache.druid.java.util.common.granularity.Granularity
- All Implemented Interfaces:
Cacheable
- Direct Known Subclasses:
AllGranularity,DurationGranularity,NoneGranularity,PeriodGranularity
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal org.joda.time.Intervalbucket(org.joda.time.DateTime t) Return a granularity-sized Interval containing a particular DateTime.org.joda.time.DateTimebucketEnd(org.joda.time.DateTime time) abstract longbucketStart(long time) abstract org.joda.time.DateTimebucketStart(org.joda.time.DateTime time) static GranularityfromString(String str) abstract org.joda.time.format.DateTimeFormatterIterable<org.joda.time.Interval>getIterable(org.joda.time.Interval input) Return an iterable of granular buckets that overlap a particular interval.org.joda.time.DateTimeZonestatic List<Granularity>Returns a list of standard granularities that are equal to, or finer than, a provided granularity.abstract longincrement(long time) abstract org.joda.time.DateTimeincrement(org.joda.time.DateTime time) abstract booleanisAligned(org.joda.time.Interval interval) Return true only if the time chunks populated by this granularity includes the given interval time chunk.booleanDecides whether this granularity is finer than the other granularitystatic GranularitymergeGranularities(List<Granularity> toMerge) simple merge strategy on query granularity that checks if all are equal or else returns null.org.joda.time.DateTimeabstract org.joda.time.DateTimetoDate(String filePath, Granularity.Formatter formatter) org.joda.time.DateTimetoDateTime(long offset) final StringtoPath(org.joda.time.DateTime time) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.druid.java.util.common.Cacheable
getCacheKey
-
Field Details
-
IS_FINER_THAN
-
-
Constructor Details
-
Granularity
public Granularity()
-
-
Method Details
-
fromString
-
mergeGranularities
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
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. The list of granularities returned contains WEEK only if the requested granularity is WEEK. -
getFormatter
-
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) -
toDate
-
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
-
toPath
-
bucket
public final org.joda.time.Interval bucket(org.joda.time.DateTime t) Return a granularity-sized Interval containing a particular DateTime. -
isFinerThan
Decides whether this granularity is finer than the other granularity- Returns:
- true if this
Granularityis finer than the passed one
-
getIterable
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 ofIntervals.ETERNITYand any granularity other thanGranularities.ALL, as well as cases like an input interval of ten years withGranularities.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.
-