@Override public boolean appliesTo(Interval theInterval, DateTime referenceTimestamp) { final DateTime periodAgo = referenceTimestamp.minus(period); return theInterval.getEndMillis() <= periodAgo.getMillis(); } }
private List<Pair<Long, Long>> makeIntervalLongs() { List<Pair<Long, Long>> intervalLongs = new ArrayList<>(); for (Interval interval : intervals) { intervalLongs.add(new Pair<Long, Long>(interval.getStartMillis(), interval.getEndMillis())); } return intervalLongs; }
private Interval trim(Interval inputInterval, Interval interval) { long start = interval.getStartMillis(); long end = interval.getEndMillis(); boolean makeNew = false; if (start < inputInterval.getStartMillis()) { start = inputInterval.getStartMillis(); makeNew = true; } if (end > inputInterval.getEndMillis()) { end = inputInterval.getEndMillis(); makeNew = true; } return makeNew ? new Interval(start, end, interval.getChronology()) : interval; }
private static double convertEnd(DataSegment dataSegment, Interval interval) { return toLocalInterval(dataSegment.getInterval().getEndMillis(), interval); }
public BenchmarkDataGenerator( List<BenchmarkColumnSchema> columnSchemas, final long seed, Interval interval, int numRows ) { this.columnSchemas = columnSchemas; this.seed = seed; this.startTime = interval.getStartMillis(); this.endTime = interval.getEndMillis() - 1; Preconditions.checkArgument(endTime >= startTime, "endTime >= startTime"); long timeDelta = endTime - startTime; this.timestampIncrement = timeDelta / (numRows * 1.0); this.numConsecutiveTimestamps = 0; init(); }
private SegmentId(String dataSource, Interval interval, String version, int partitionNum) { this.dataSource = STRING_INTERNER.intern(Objects.requireNonNull(dataSource)); this.intervalStartMillis = interval.getStartMillis(); this.intervalEndMillis = interval.getEndMillis(); this.intervalChronology = interval.getChronology(); // Versions are timestamp-based Strings, interning of them doesn't make sense. If this is not the case, interning // could be conditionally allowed via a system property. this.version = Objects.requireNonNull(version); this.partitionNum = partitionNum; this.hashCode = computeHashCode(); }
public static boolean eligibleForLoad(Period period, Interval interval, DateTime referenceTimestamp, boolean includeFuture) { final Interval currInterval = new Interval(period, referenceTimestamp); if (includeFuture) { return currInterval.getStartMillis() < interval.getEndMillis(); } else { return eligibleForLoad(currInterval, interval); } }
/** * Creates a new interval with the same start and end, but a different chronology. * * @param chronology the chronology to use, null means ISO default * @return an interval with a different chronology */ public Interval withChronology(Chronology chronology) { if (getChronology() == chronology) { return this; } return new Interval(getStartMillis(), getEndMillis(), chronology); }
/** * Creates a new interval with the specified end millisecond instant. * * @param endInstant the end instant for the new interval * @return an interval with the start from this interval and the specified end * @throws IllegalArgumentException if the resulting interval has end before start */ public Interval withEndMillis(long endInstant) { if (endInstant == getEndMillis()) { return this; } return new Interval(getStartMillis(), endInstant, getChronology()); }
/** * Creates a new interval with the specified start millisecond instant. * * @param startInstant the start instant for the new interval * @return an interval with the end from this interval and the specified start * @throws IllegalArgumentException if the resulting interval has end before start */ public Interval withStartMillis(long startInstant) { if (startInstant == getStartMillis()) { return this; } return new Interval(startInstant, getEndMillis(), getChronology()); }
/** * Creates a new interval with the same start and end, but a different chronology. * * @param chronology the chronology to use, null means ISO default * @return an interval with a different chronology */ public Interval withChronology(Chronology chronology) { if (getChronology() == chronology) { return this; } return new Interval(getStartMillis(), getEndMillis(), chronology); }
/** * Creates a new interval with the specified start millisecond instant. * * @param startInstant the start instant for the new interval * @return an interval with the end from this interval and the specified start * @throws IllegalArgumentException if the resulting interval has end before start */ public Interval withStartMillis(long startInstant) { if (startInstant == getStartMillis()) { return this; } return new Interval(startInstant, getEndMillis(), getChronology()); }
/** * Creates a new interval with the specified end millisecond instant. * * @param endInstant the end instant for the new interval * @return an interval with the start from this interval and the specified end * @throws IllegalArgumentException if the resulting interval has end before start */ public Interval withEndMillis(long endInstant) { if (endInstant == getEndMillis()) { return this; } return new Interval(getStartMillis(), endInstant, getChronology()); }
public static RangeSet<Long> fromIntervals(final Iterable<Interval> intervals) { final RangeSet<Long> retVal = TreeRangeSet.create(); for (Interval interval : intervals) { retVal.add(Range.closedOpen(interval.getStartMillis(), interval.getEndMillis())); } return retVal; }
private static Iterable<Interval> splitInterval(Interval interval, Period period) { if (interval.getEndMillis() == interval.getStartMillis()) { return Collections.singletonList(interval); } List<Interval> intervals = new ArrayList<>(); Iterator<Interval> timestamps = new PeriodGranularity(period, null, null).getIterable(interval).iterator(); DateTime start = DateTimes.max(timestamps.next().getStart(), interval.getStart()); while (timestamps.hasNext()) { DateTime end = timestamps.next().getStart(); intervals.add(new Interval(start, end)); start = end; } if (start.compareTo(interval.getEnd()) < 0) { intervals.add(new Interval(start, interval.getEnd())); } return intervals; }
@Override public int compare(Interval lhs, Interval rhs) { if (lhs.getChronology().equals(rhs.getChronology())) { int compare = Long.compare(lhs.getEndMillis(), rhs.getEndMillis()); if (compare == 0) { return Long.compare(lhs.getStartMillis(), rhs.getStartMillis()); } return compare; } int retVal = dateTimeComp.compare(lhs.getEnd(), rhs.getEnd()); if (retVal == 0) { retVal = dateTimeComp.compare(lhs.getStart(), rhs.getStart()); } return retVal; } };
@Override public int compare(Interval lhs, Interval rhs) { if (lhs.getChronology().equals(rhs.getChronology())) { int compare = Long.compare(lhs.getStartMillis(), rhs.getStartMillis()); if (compare == 0) { return Long.compare(lhs.getEndMillis(), rhs.getEndMillis()); } return compare; } int retVal = dateTimeComp.compare(lhs.getStart(), rhs.getStart()); if (retVal == 0) { retVal = dateTimeComp.compare(lhs.getEnd(), rhs.getEnd()); } return retVal; } };
public static BoundDimFilter interval(final BoundRefKey boundRefKey, final Interval interval) { if (!boundRefKey.getComparator().equals(StringComparators.NUMERIC)) { // Interval comparison only works with NUMERIC comparator. throw new ISE("Comparator must be NUMERIC but was[%s]", boundRefKey.getComparator()); } return new BoundDimFilter( boundRefKey.getDimension(), String.valueOf(interval.getStartMillis()), String.valueOf(interval.getEndMillis()), false, true, null, boundRefKey.getExtractionFn(), boundRefKey.getComparator() ); } }
/** * Creates a new interval with the specified period before the end instant. * * @param period the period to subtract from the end to get the new start instant, null means zero * @return an interval with the end from this interval and a calculated start * @throws IllegalArgumentException if the period is negative */ public Interval withPeriodBeforeEnd(ReadablePeriod period) { if (period == null) { return withDurationBeforeEnd(null); } Chronology chrono = getChronology(); long endMillis = getEndMillis(); long startMillis = chrono.add(period, endMillis, -1); return new Interval(startMillis, endMillis, chrono); }
public static BoundDimFilter TIME_BOUND(final Object intervalObj) { final Interval interval = new Interval(intervalObj, ISOChronology.getInstanceUTC()); return new BoundDimFilter( ColumnHolder.TIME_COLUMN_NAME, String.valueOf(interval.getStartMillis()), String.valueOf(interval.getEndMillis()), false, true, null, null, StringComparators.NUMERIC ); }