【发布时间】:2018-12-11 12:23:50
【问题描述】:
我想我有一个产生两个输出的函数(如果我错了,请纠正我):
PCollection<String> words = ...;
final TupleTag<String> shortWordsTag = new TupleTag<String>(){};
PCollectionTuple results =
words.apply(
ParDo
.of(new DoFn<String, String>() {
@ProcessElement
public void processElement(ProcessContext context) {
String word = context.element();
if (word.length() < 5) {
context.output(shortWordsTag, word);
} else {
context.output(word);
}
现在我想调用另一个函数,但只应用其中一个输出。像这样的:
results.apply(
ParDo
.of(new DoFn<String, String>() {
@ProcessElement
public void processElement(ProcessContext context) {
String word = context.element();
// do stuff, but should only have words with length < 5 here
}
)
我可以看到一些使用withOutputTags 的示例,但这种方法似乎需要多个标签(一个标签和一个标签列表),我不确定如何在我的场景中使用它。
我如何指定我的results.apply 仅被输出到shortWordsTag 标签的数据调用?
【问题讨论】:
标签: java google-cloud-dataflow apache-beam