@Override public DateTime toDate(String filePath, Formatter formatter) { Integer[] vals = getDateValues(filePath, formatter); GranularityType granularityType = GranularityType.fromPeriod(period); DateTime date = granularityType.getDateTime(vals); if (date != null) { return bucketStart(date); } return null; }
@Override public String toString() { return "{type=period, " + "period=" + getPeriod() + ", timeZone=" + getTimeZone() + ", origin=" + getOrigin() + '}'; }
Granularity create(DateTime origin, DateTimeZone tz) { if (period != null && (origin != null || tz != null)) { return new PeriodGranularity(period, origin, tz); } else { // If All or None granularity, or if origin and tz are both null, return the cached granularity return defaultGranularity; } }
public DateTime bucketEnd(DateTime time) { return increment(bucketStart(time)); }
GranularityType(GranularityType granularityType, String period) { this( granularityType.getHiveFormat(), granularityType.getLowerDefaultFormat(), granularityType.getDefaultFormat(), granularityType.dateValuePositions, period ); }
@Override public DateTime bucketStart(DateTime time) { return new DateTime(truncate(time.getMillis()), getTimeZone()); }
@Override public DateTime increment(DateTime time) { return new DateTime(increment(time.getMillis()), getTimeZone()); }
@Override public DateTimeZone getTimezone() { return granularity instanceof PeriodGranularity ? ((PeriodGranularity) granularity).getTimeZone() : DateTimeZone.UTC; }
public DateTime toDate(String filePath) { return toDate(filePath, Formatter.DEFAULT); }
@Override public void serializeWithType( JsonGenerator jsonGenerator, SerializerProvider serializerProvider, TypeSerializer typeSerializer ) throws IOException { serialize(jsonGenerator, serializerProvider); } }
@Override public Iterator<Interval> iterator() { return new IntervalIterator(inputInterval); }
public TimeseriesQueryBuilder granularity(String g) { granularity = Granularity.fromString(g); return this; }
public Iterable<Interval> getIterable(final Interval input) { return new IntervalIterable(input); }
@Override public DateTime increment(DateTime time) { return time.plus(getDuration()); }
@Override public DateTime bucketStart(DateTime time) { long t = time.getMillis(); final long duration = getDurationMillis(); long offset = t % duration - origin; if (offset < 0) { offset += duration; } return new DateTime(t - offset, time.getChronology()); }
/** * Return a granularity-sized Interval containing a particular DateTime. */ public final Interval bucket(DateTime t) { DateTime start = bucketStart(t); return new Interval(start, increment(start)); }
@Override public byte[] getCacheKey() { return StringUtils.toUtf8(getPeriod() + ":" + getTimeZone() + ":" + getOrigin()); }
@Override public DateTime toDateTime(long offset) { return new DateTime(offset, getTimeZone()); }
private IntervalIterator(Interval inputInterval) { this.inputInterval = inputInterval; currStart = bucketStart(inputInterval.getStart()); currEnd = increment(currStart); }