Skip to content

Instantly share code, notes, and snippets.

@imrenagi
Created January 8, 2019 23:25
Show Gist options
  • Select an option

  • Save imrenagi/602e48f3eeada26e32f18ab4166fe55a to your computer and use it in GitHub Desktop.

Select an option

Save imrenagi/602e48f3eeada26e32f18ab4166fe55a to your computer and use it in GitHub Desktop.
final TupleTag<String> dataTag = new TupleTag<String>() {};
final TupleTag<String> errorTag = new TupleTag<String>() {};
PCollectionTuple mixedCollection =
names.apply(ParDo
.of(new DoFn<String, String>() {
@ProcessElement
public void processElement(ProcessContext c) {
if (c.element().startsWith("Foo")) {
c.output(c.element());
} else if (c.element().startsWith("Bar")) {
c.output(errorTag, c.element());
}
}
}).withOutputTags(dataTag, TupleTagList.of(errorTag)));
mixedCollection.get(dataTag).apply(...);
mixedCollection.get(errorTag).apply(...);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment