当A不产生任何输出时,有没有办法让PTransform B依赖PTransform A?或者我必须让A产生一个虚拟输出,作为侧输入馈入B?一个示例用例是我想拥有以下管道:
Z = read file
A = count lines in file, and throw error if there are no lines
B = do something with the file
我希望B仅在A完成后启动,但A不会产生对B有用的任何输出PCollection。
答案 0 :(得分:3)
这是可能的,但在您的情况下可能并不是真的可取。添加这样的依赖项会减慢程序的并行执行速度,因为B需要等待A完成才能启动。
如果你真的想这样做,你所描述的方式 - 输出一个元素并将其用作B的侧输入应该有效。请考虑以下内容,它允许您使用原始Count
转换来实现A,并将所有逻辑移动到一个位置:
Z = read file
A = count lines in file
B = side input from A, throw error if the count of lines was zero,
otherwise do something with the file