gpt4 book ai didi

google-cloud-dataflow - GroupByKey 转换的早期结果

转载 作者:行者123 更新时间:2023-12-02 01:03:47 25 4
gpt4 key购买 nike

我怎样才能让 GroupByKey 触发早期结果,而不是等待所有数据到达(在我的情况下这是相当长的时间)。我试图通过早期触发将我的输入 PCollection 拆分到窗口中,但是它只是行不通。在给出结果之前,它仍然等待所有数据到达。

PCollection<List<String>> input = ...
PCollection<KV<Integer,List<String>>> keyedInput = input.apply(ParDo.of(new AddArbitraryKey()))
keyedInput.apply(Window<KV<Integer,List<String>>>into(
FixedWindows.of(Duration.standardSeconds(1)))
.triggering(Repeatedly.forever(AfterWatermark.pastEndOfWindow()))
.withAllowedLateness(Duration.ZERO).discardingFiredPanes())
.apply(GroupByKey.<Integer,List<String>>create())
.apply(ParDo.of(new RemoveArbitraryKey()))
.apply(ParDo.of(new FurtherProcessing())

我这样做是为了防止 fusing . AddArbitraryKey 转换输出其带有时间戳的元素。但是,GroupByKey 会保留所有数据,直到所有数据都到达(对于所有窗口)。有人可以告诉我如何让它提前触发吗?谢谢你 。

最佳答案

你可以安装一个触发器,比如

Repeatedly
.forever(AfterProcessingTime
.pastFirstElementInPane()
.plusDuration(Duration.standardMinutes(1))
.orFinally(AfterWatermark.pastEndOfWindow())
.discardingFiredPanes()

或者

AfterWatermark.pastEndOfWindow()
.withEarlyFirings(
AfterProcessingTime
.pastFirstElementInPane()
.plusDuration(Duration.standardMinutes(1))

关于google-cloud-dataflow - GroupByKey 转换的早期结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48886943/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com