我正在使用 Apache Beam 设置一个由 2 个主要步骤组成的管道:
- 使用 Beam Transform 来转换数据
- 将转换后的数据加载到 BigQuery
管道设置如下所示:
myPCollection = (org.apache.beam.sdk.values.PCollection<myCollectionObjectType>)myInputPCollection
.apply("do a parallel transform"),
ParDo.of(new MyTransformClassName.MyTransformFn()));
myPCollection
.apply("Load BigQuery data for PCollection",
BigQueryIO.<myCollectionObjectType>write()
.to(new MyDataLoadClass.MyFactTableDestination(myDestination))
.withFormatFunction(new MyDataLoadClass.MySerializationFn())
我看过这个问题:
Apache Beam:跳过已构建的管道中的步骤
这表明我可以按照步骤 1 中的并行转换以某种方式动态更改可以将数据传递到的输出。
我该怎么做呢?不知道如何选择通过或不通过myPCollection
从步骤1到步骤2。如果对象在myPCollection
从步骤 1 开始是null
.
你只是不从你的MyTransformClassName.MyTransformFn
当您不想在下一步中使用它时,例如如下所示:
class MyTransformClassName.MyTransformFn extends...
@ProcessElement
public void processElement(ProcessContext c, ...) {
...
result = ...
if (result != null) {
c.output(result); //only output something that's not null
}
}
这样空值就不会到达下一步。
See the ParDo
指南部分了解更多详细信息:https://beam.apache.org/documentation/programming-guide/#pardo
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)