/** * Checks if the provided range r is within the current range. * Note that equal ranges also returns true. * * @param r range * @return true if range r is contained in r */ public boolean contains(Range r) { if ((this.beginTime().getJodaTimeInstant().isBefore(r.beginTime().getJodaTimeInstant()) || this.beginTime().getJodaTimeInstant().isEqual(r.beginTime().getJodaTimeInstant())) && (this.endTime().getJodaTimeInstant().isAfter(r.endTime().getJodaTimeInstant()) || this.endTime().getJodaTimeInstant().isEqual(r.endTime().getJodaTimeInstant()))) { return true; } return false; }
public Context withDeadline(Instant deadline) { if (this.deadline != null && this.deadline.isBefore(deadline)) { // You can't make a derived context with a later deadline than the parent. return this; } return new Context(deadline, callerId); }
public Context withDeadline(Instant deadline) { if (this.deadline != null && this.deadline.isBefore(deadline)) { // You can't make a derived context with a later deadline than the parent. return this; } return new Context(deadline, callerId); }
@Override public Instant addInput(Instant accumulator, Instant input) { return accumulator.isBefore(input) ? input : accumulator; }
@Override public Instant getWatermarkThatGuaranteesFiring(BoundedWindow window) { // This trigger fires once either the trigger or the until trigger fires. Instant actualDeadline = subTriggers.get(ACTUAL).getWatermarkThatGuaranteesFiring(window); Instant untilDeadline = subTriggers.get(UNTIL).getWatermarkThatGuaranteesFiring(window); return actualDeadline.isBefore(untilDeadline) ? actualDeadline : untilDeadline; }
/** Advances the watermark in the next batch. */ public CreateStream<T> advanceWatermarkForNextBatch(Instant newWatermark) { checkArgument( !newWatermark.isBefore(lowWatermark), "The watermark is not allowed to decrease!"); checkArgument( newWatermark.isBefore(BoundedWindow.TIMESTAMP_MAX_VALUE), "The Watermark cannot progress beyond the maximum. Got: %s. Maximum: %s", newWatermark, BoundedWindow.TIMESTAMP_MAX_VALUE); return advance(newWatermark); }
/** Is {@code window} expired w.r.t. the garbage collection watermark? */ private boolean canDropDueToExpiredWindow(BoundedWindow window) { Instant inputWM = timerInternals.currentInputWatermarkTime(); return LateDataUtils.garbageCollectionTime(window, windowingStrategy).isBefore(inputWM); } }
private Instant minTimestamp(Iterable<Visit> goals, Visit goalToSkip) { Instant min = null; for (Visit goal : goals) { if (goal != goalToSkip && (min == null || goal.timestamp().isBefore(min))) { min = goal.timestamp(); } } return min; }
private static Instant minTimestamp(Iterable<? extends WindowedValue<?>> elements) { Instant minTs = BoundedWindow.TIMESTAMP_MAX_VALUE; for (WindowedValue<?> element : elements) { if (element.getTimestamp().isBefore(minTs)) { minTs = element.getTimestamp(); } } return minTs; } }
private static Instant minTimestamp(Iterable<? extends WindowedValue<?>> elements) { Instant minTs = BoundedWindow.TIMESTAMP_MAX_VALUE; for (WindowedValue<?> element : elements) { if (element.getTimestamp().isBefore(minTs)) { minTs = element.getTimestamp(); } } return minTs; } }
/** Returns true if the step will not produce additional output. */ public boolean isDone(PTransformNode transform) { // the PTransform is done only if watermark is at the max value Instant stepWatermark = watermarkManager.getWatermarks(transform).getOutputWatermark(); return !stepWatermark.isBefore(BoundedWindow.TIMESTAMP_MAX_VALUE); }
/** Returns true if the step will not produce additional output. */ public boolean isDone(AppliedPTransform<?, ?, ?> transform) { // the PTransform is done only if watermark is at the max value Instant stepWatermark = watermarkManager.getWatermarks(transform).getOutputWatermark(); return !stepWatermark.isBefore(BoundedWindow.TIMESTAMP_MAX_VALUE); }
private boolean isLate(BoundedWindow window) { Instant gcTime = LateDataUtils.garbageCollectionTime(window, windowingStrategy); Instant inputWM = cleanupTimer.currentInputWatermarkTime(); return gcTime.isBefore(inputWM); }
@Internal @Override public Instant getWatermarkThatGuaranteesFiring(BoundedWindow window) { // This trigger will fire after the latest of its sub-triggers. Instant deadline = BoundedWindow.TIMESTAMP_MIN_VALUE; for (Trigger subTrigger : subTriggers) { Instant subDeadline = subTrigger.getWatermarkThatGuaranteesFiring(window); if (deadline.isBefore(subDeadline)) { deadline = subDeadline; } } return deadline; }
private static Instant getEventsStart(boolean orderByRemoteTime) { String timeField = timeFieldForOrdering(orderByRemoteTime); Instant bookStart = EM.queryOne(Instant.class, "select min(" + timeField + ") from Book"); Instant tradeStart = EM.queryOne(Instant.class, "select min(" + timeField + ") from Trade"); if (bookStart == null && tradeStart == null) return null; if (bookStart == null) return tradeStart; if (tradeStart == null) return bookStart; return tradeStart.isBefore(bookStart) ? tradeStart : bookStart; }
public void set(Instant newNow) { checkArgument( !newNow.isBefore(now), "Cannot move MockClock backwards in time from %s to %s", now, newNow); this.now = newNow; }
@Override public Instant mergeAccumulators(Iterable<Instant> accumulators) { Instant v = new Instant(0L); for (Instant accumulator : accumulators) { v = accumulator.isBefore(v) ? v : accumulator; } return v; }
public void set(Instant newNow) { checkArgument( !newNow.isBefore(now), "Cannot move MockClock backwards in time from %s to %s", now, newNow); this.now = newNow; }
@Override public TimestampedValue<T> addInput( TimestampedValue<T> accumulator, TimestampedValue<T> input) { checkNotNull(accumulator, "accumulator must be non-null"); checkNotNull(input, "input must be non-null"); if (input.getTimestamp().isBefore(accumulator.getTimestamp())) { return accumulator; } else { return input; } }
protected void checkTimestamp(WindowedValue<IN> ref, Instant timestamp) { if (timestamp.isBefore(ref.getTimestamp().minus(doFn.getAllowedTimestampSkew()))) { throw new IllegalArgumentException(String.format( "Cannot output with timestamp %s. Output timestamps must be no earlier than the " + "timestamp of the current input (%s) minus the allowed skew (%s). See the " + "DoFn#getAllowedTimestmapSkew() Javadoc for details on changing the allowed skew.", timestamp, ref.getTimestamp(), PeriodFormat.getDefault().print(doFn.getAllowedTimestampSkew().toPeriod()))); } }