使用时间作为输入的 Apache Beam

Apache Beam that uses time as an input

我想创建一个每秒执行一次的 Beam 输入,并将时间作为输入输出。我知道我可以从这样的数字中收集数据

p.apply(Create.of(1, 2, 3, 4, 5))
        .setCoder(VarIntCoder.of())

而且我可以创建一个非常大的数字数组,并且 window 它们每秒都是,但是有没有更好的方法来做到这一点?谢谢

发现这可以通过 GenerateSequence 用于有界或无界集。为了每秒获得 1 个数据点,我可以使用 withRate 函数,如果我不包含 "to" 那么我的 pcollection 将是无限的。

p.apply(GenerateSequence.from(0).withRate(1, new Duration(1000)))