@DoFn.ProcessElement public void processElement(ProcessContext c) throws IOException { if (schema == null) { schema = new Schema.Parser().parse(schemaStr); datumReader = new GenericDatumReader<GenericRecord>(schema); } decoder = DecoderFactory.get().binaryDecoder(c.element().getDataAsBytes(), decoder); GenericRecord record = datumReader.read(null, decoder); c.output(record); } }
@DoFn.ProcessElement public void processElement(ProcessContext c) throws IOException { String record = new String(c.element().getDataAsBytes(), Charset.forName("UTF-8")); String[] data = record.split(fieldDelimiter); if (schema == null) { schema = inferStringArray(data); } c.output(new StringArrayIndexedRecord(schema, data)); } }
@DoFn.ProcessElement public void processElement(DoFn<KV<String, Iterable<BAMShard>>, BAMShard>.ProcessContext c) { for (BAMShard shard : c.element().getValue()) { c.output(shard); } } }))
@DoFn.ProcessElement public void processElement( @DoFn.Element KV<KeyT, ValueT> element, OutputReceiver<KV<Integer, KV<KeyT, ValueT>>> output, ProcessContext c) { if (taskId == null) { Configuration conf = c.sideInput(configView); taskId = externalSynchronization.acquireTaskIdLock(conf); } output.output(KV.of(taskId.getId(), element)); } }
@DoFn.ProcessElement public void processElement(ProcessContext c) throws IOException { if (schema == null) { schema = new Schema.Parser().parse(schemaStr); datumReader = new GenericDatumReader<GenericRecord>(schema); } decoder = DecoderFactory.get().binaryDecoder(c.element(), decoder); GenericRecord record = datumReader.read(null, decoder); c.output(record); } }
@ProcessElement public void processElement(MultiOutputReceiver r) { r.get(mainOutputTag).output(new TestDummy()); r.get(intOutputTag).output(1); } }
@ProcessElement public void process( ProcessContext c, BoundedWindow w, @TimerId(timerId) Timer timer) { timer.set(w.maxTimestamp()); }
@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(timerId) Timer timer, OutputReceiver<Integer> r) { timer.offset(Duration.standardSeconds(1)).setRelative(); r.output(3); }
@ProcessElement public void processElement(@TimerId(timerId) Timer timer, OutputReceiver<Integer> r) { timer.offset(Duration.standardSeconds(1)).setRelative(); r.output(3); }
@ProcessElement public void processElement( @Element KV<String, Integer> element, @StateId(stateId) CombiningState<Integer, MyInteger, Integer> state, OutputReceiver<String> r) { state.add(element.getValue()); Integer currentValue = state.read(); if (currentValue == EXPECTED_SUM) { r.output("right on"); } } };
@ProcessElement public void processElement( @StateId(stateId) ValueState<Integer> state, OutputReceiver<Integer> r) { Integer currentValue = MoreObjects.firstNonNull(state.read(), 0); r.output(currentValue); state.write(currentValue + 1); } };
@ProcessElement public void processElement( @Element KV<Integer, Integer> element, @StateId(stateId) ValueState<Integer> seenState, OutputReceiver<Integer> r) { Integer seen = MoreObjects.firstNonNull(seenState.read(), 0); if (seen == 0) { seenState.write(seen + 1); r.output(element.getValue()); } } };
@ProcessElement public void processElement( @StateId(stateId) ValueState<Integer> state, OutputReceiver<Integer> r) { Integer currentValue = MoreObjects.firstNonNull(state.read(), 0); r.output(currentValue); state.write(currentValue + 1); } };
@ProcessElement public void processElement( @Element Integer element, MultiOutputReceiver r) { r.get(additionalOutputTag) .outputWithTimestamp(element, new Instant(element.longValue())); } })
@ProcessElement public void processElement( ProcessContext context, @Element TestDummy element) { context.output(element); context.output(additionalOutputTag, element); } })
@ProcessElement public void processElement( @Element T element, @Timestamp Instant timestamp, OutputReceiver<String> r) { checkNotNull(timestamp); r.output("processing: " + element + ", timestamp: " + timestamp.getMillis()); } }
@ProcessElement public void processElement(ProcessContext c) { throw new RuntimeException("test error in process"); } }
@ProcessElement public void processElement(ProcessContext c, @Element Integer element) { assertThat(state, anyOf(equalTo(State.STARTED), equalTo(State.PROCESSING))); state = State.PROCESSING; outputToAllWithSideInputs(c, "processing: " + element); }
@DoFn.ProcessElement public void processElement(DoFn<BAMShard, KV<String, BAMShard>>.ProcessContext c) throws Exception { c.output(KV.of(c.element().toString(), c.element())); } }))