@ProcessElement public void process( ProcessContext c, BoundedWindow w, @TimerId(timerId) Timer timer) { timer.set(w.maxTimestamp()); }
@ProcessElement public void process(ProcessContext context, @TimerId(TIMER_ID) Timer timer) { timer.offset(TIMER_OFFSET).setRelative(); }
@ProcessElement public void processElement( @TimerId(timerId) Timer timer, @Timestamp Instant timestamp, OutputReceiver<KV<Integer, Instant>> r) { timer.align(Duration.standardSeconds(1)).offset(Duration.millis(1)).setRelative(); r.output(KV.of(3, timestamp)); }
@ProcessElement public void processElement(ProcessContext context, @TimerId(timerId) Timer timer) { // This aligned time will exceed the END_OF_GLOBAL_WINDOW timer.align(Duration.standardDays(1)).setRelative(); context.output(KV.of(3, context.timestamp())); }
@ProcessElement public void processElement( @TimerId(END_OF_WINDOW_ID) Timer timer, @StateId(BATCH_ID) BagState<InputT> batch, @StateId(NUM_ELEMENTS_IN_BATCH_ID) CombiningState<Long, long[], Long> numElementsInBatch, @StateId(KEY_ID) ValueState<K> key, @Element KV<K, InputT> element, BoundedWindow window, OutputReceiver<KV<K, Iterable<InputT>>> receiver) { Instant windowExpires = window.maxTimestamp().plus(allowedLateness); LOG.debug( "*** SET TIMER *** to point in time {} for window {}", windowExpires.toString(), window.toString()); timer.set(windowExpires); key.write(element.getKey()); batch.add(element.getValue()); LOG.debug("*** BATCH *** Add element for window {} ", window.toString()); // blind add is supported with combiningState numElementsInBatch.add(1L); Long num = numElementsInBatch.read(); if (num % prefetchFrequency == 0) { //prefetch data and modify batch state (readLater() modifies this) batch.readLater(); } if (num >= batchSize) { LOG.debug("*** END OF BATCH *** for window {}", window.toString()); flushBatch(receiver, key, batch, numElementsInBatch); } }
@ProcessElement public void process(ProcessContext c, @TimerId("timer") Timer timer) { timer.offset(Duration.standardMinutes(10)).setRelative(); timer.offset(Duration.standardMinutes(30)).setRelative(); }
@ProcessElement public void processElement( @TimerId(timerId) Timer timer, @Timestamp Instant timestamp, OutputReceiver<KV<Integer, Instant>> r) { timer.align(Duration.standardSeconds(1)).offset(Duration.millis(1)).setRelative(); r.output(KV.of(3, timestamp)); }
@ProcessElement public void processElement(@TimerId(timerId) Timer timer) { try { timer.set(new Instant(0)); fail("Should have failed due to processing time with absolute timer."); } catch (RuntimeException e) { String message = e.getMessage(); List<String> expectedSubstrings = Arrays.asList("relative timers", "processing time"); expectedSubstrings.forEach( str -> Preconditions.checkState( message.contains(str), "Pipeline didn't fail with the expected strings: %s", expectedSubstrings)); } }
@ProcessElement public void processElement( @StateId(stateId) ValueState<Integer> countState, @TimerId(timerId) Timer loopTimer) { loopTimer.offset(Duration.millis(1)).setRelative(); }
@ProcessElement public void processElement( ProcessContext context, BoundedWindow window, @TimerId(timerId) Timer timer) { try { timer.set(window.maxTimestamp().plus(1L)); fail("Should have failed due to processing time with absolute timer."); } catch (RuntimeException e) { String message = e.getMessage(); List<String> expectedSubstrings = Arrays.asList("event time timer", "expiration"); expectedSubstrings.forEach( str -> Preconditions.checkState( message.contains(str), "Pipeline didn't fail with the expected strings: %s", expectedSubstrings)); } }
@ProcessElement public void processElement(ProcessContext context, @TimerId(timerId) Timer timer) { timer.offset(Duration.standardSeconds(1)).setRelative(); context.output(3); }
@ProcessElement public void processElement( @TimerId(timerId) Timer timer, BoundedWindow window, OutputReceiver<Integer> r) { timer.set(window.maxTimestamp()); r.output(3); }
@ProcessElement public void processElement(@TimerId(timerId) Timer timer) { timer.offset(Duration.standardSeconds(1)).setRelative(); }
if (minTimestamp == null || visit.timestamp().isBefore(minTimestamp)) { LOG.info("Setting timer from {} to {}", Utils.formatTime(minTimestamp), Utils.formatTime(visit.timestamp())); attributionTimer.set(visit.timestamp()); minGoalState.write(visit.timestamp());
@ProcessElement public void processElement(@TimerId(timerId) Timer timer, OutputReceiver<Integer> r) { timer.offset(Duration.standardSeconds(1)).setRelative(); r.output(3); }
LOG.info("Setting new timer at {}", Utils.formatTime(minGoal)); minGoalState.write(minGoal); attributionTimer.set(minGoal); } else { minGoalState.clear();
@ProcessElement public void processElement(@TimerId(timerId) Timer timer, OutputReceiver<Integer> r) { timer.offset(Duration.standardSeconds(1)).setRelative(); r.output(3); }
@ProcessElement public void processElement( ProcessContext context, @TimerId(timerId) Timer timer, @StateId(stateId) ValueState<String> state, BoundedWindow window) { timer.set(window.maxTimestamp()); state.write(context.element().getKey()); context.output( KV.of(context.element().getKey(), context.element().getValue() + offset)); }
@ProcessElement public void processElement(@TimerId(TIMER_ID) Timer timer, OutputReceiver<Integer> r) { timer.offset(Duration.standardSeconds(1)).setRelative(); r.output(3); }
@ProcessElement public void processElement( ProcessContext context, @TimerId(timerId) Timer timer, @StateId(stateId) ValueState<String> state, BoundedWindow window) { timer.set(window.maxTimestamp()); state.write(context.element().getKey()); context.output( KV.of(context.element().getKey(), context.element().getValue() + offset)); }