@ProcessElement public void processElement(@Element String input, OutputReceiver<KV<String, Integer>> output) { String[] parts = input.split(","); String team = parts[1].trim(); Integer score = Integer.parseInt(parts[2].trim()); Instant eventTime = Instant.parse(parts[3].trim()); output.outputWithTimestamp(KV.of(team, score), eventTime); } }
@ProcessElement public void processElement(@Element String element, OutputReceiver<String> receiver) { Instant randomTimestamp = new Instant( ThreadLocalRandom.current() .nextLong(minTimestamp.getMillis(), maxTimestamp.getMillis())); /* * Concept #2: Set the data element with that timestamp. */ receiver.outputWithTimestamp(element, new Instant(randomTimestamp)); } }
@ProcessElement public void processElement(@Element T value, OutputReceiver<T> r) { r.outputWithTimestamp(value, new Instant(value.longValue())); } }
@ProcessElement public void process( @Element Shard<T> shard, OutputReceiver<ValueWithRecordId<T>> out, PipelineOptions options) throws Exception { Instant endTime = shard.getMaxReadTime() == null ? null : Instant.now().plus(shard.getMaxReadTime()); if (shard.getMaxNumRecords() <= 0 || (shard.getMaxReadTime() != null && shard.getMaxReadTime().getMillis() == 0)) { return; } try (UnboundedSource.UnboundedReader<T> reader = SerializableUtils.clone(shard.getSource()).createReader(options, null)) { for (long i = 0L; i < shard.getMaxNumRecords(); ++i) { boolean available = (i == 0) ? reader.start() : reader.advance(); if (!available && !advanceWithBackoff(reader, endTime)) { break; } out.outputWithTimestamp( new ValueWithRecordId<T>(reader.getCurrent(), reader.getCurrentRecordId()), reader.getCurrentTimestamp()); } reader.getCheckpointMark().finalizeCheckpoint(); } }
@ProcessElement public void process(@Element Integer e, MultiOutputReceiver r) { for (int i = 0; i < e; i++) { r.get(food) .outputWithTimestamp( KV.of("foo", e), new Instant(0).plus(Duration.standardHours(i))); } r.get(originals).output(e); } })
@ProcessElement public void processElement( @Element T value, @Timestamp Instant timestamp, OutputReceiver<T> r) { checkNotNull(timestamp); r.outputWithTimestamp(value, timestamp.plus(durationToShift)); } }
@ProcessElement public void processElement(@Element TimestampedValue<T> element, OutputReceiver<T> r) { r.outputWithTimestamp(element.getValue(), element.getTimestamp()); } }
@ProcessElement public void processElement( @Element T element, @Timestamp Instant timestamp, BoundedWindow window, PaneInfo pane, OutputReceiver<ValueInSingleWindow<T>> r) { r.outputWithTimestamp( ValueInSingleWindow.of(element, timestamp, window, pane), timestamp); } }))
@ProcessElement public void processElement( @Element Integer element, MultiOutputReceiver r) { r.get(additionalOutputTag) .outputWithTimestamp(element, new Instant(element.longValue())); } })
@ProcessElement public void processElement(@Element T element, OutputReceiver<T> r) { Instant timestamp = fn.apply(element); checkNotNull( timestamp, "Timestamps for WithTimestamps cannot be null. Timestamp provided by %s.", fn); r.outputWithTimestamp(element, timestamp); }
@ProcessElement public void processElement( @Element KV<K, TimestampedValue<V>> kv, OutputReceiver<KV<K, V>> r) { r.outputWithTimestamp( KV.of(kv.getKey(), kv.getValue().getValue()), kv.getValue().getTimestamp()); } }))