数据流 - 已修复 Window- AfterProcessingTrigger
Dataflow - Fixed Window- AfterProcessingTrigger
我使用固定的 window 60 秒,触发时间为 10 秒。我几乎没有遇到意想不到的结果。你能帮我理解一下我在下面提供的细节吗works.All。
我对 pubsub 主题的输入是:
*name* *score* publish timestamp(every 5 seconds I am publishing one element)
Laia 30 2021-04-10 09:38:29.708000+0000
Victor 20 2021-04-10 09:38:34.695000+0000
Victor 50 2021-04-10 09:38:39.703000+0000
Laia 40 2021-04-10 09:38:44.701000+0000
Victor 10 2021-04-10 09:38:49.711000+0000
Victor 40 2021-04-10 09:38:54.721000+0000
Laia 40 2021-04-10 09:38:59.715000+0000
Laia 50 2021-04-10 09:39:04.741000+0000
Laia 20 2021-04-10 09:39:09.867000+0000
Laia 20 2021-04-10 09:39:14.749000+0000
我的代码:
window_withTrigger =(字数
| "window" >> beam.WindowInto(beam.window.FixedWindows(60),
trigger=AfterProcessingTime(1 * 10),
accumulation_mode= AccumulationMode.ACCUMULATING)
| "Group" >> GroupByKey())
window_withoutTrigger = (字数
| "window" >> beam.WindowInto(beam.window.FixedWindows(60))
| "Group" >> GroupByKey())
O/P 对于 window_withTrigger:
Laia [30]
Victor [20, 50, 10, 40]
Laia [50, 20, 20]
O/P 对于 window_withoutTrigger:
Laia [30, 40, 40]
Victor [20, 50, 10, 40]
Laia [50, 20, 20]
没有触发器的输出我得到了我发布到主题的所有 10 个元素,有触发器我得到了 8 个元素。我注意到触发器不会在 10 秒内发出结果,如果键项没有变化,即只有当 i/p 名称从 laila 更改为 victor 时它才会发出结果,一旦它发出 window 即使我使用相同的密钥发布它也不会再次发出。
您可能因为没有使用 Repeatedly
而删除了元素。
这里有另一个 解释了这一点。基本上这个想法是,如果你不添加 Repeatedly
,触发器只会触发一次。
我使用固定的 window 60 秒,触发时间为 10 秒。我几乎没有遇到意想不到的结果。你能帮我理解一下我在下面提供的细节吗works.All。
我对 pubsub 主题的输入是:
*name* *score* publish timestamp(every 5 seconds I am publishing one element)
Laia 30 2021-04-10 09:38:29.708000+0000
Victor 20 2021-04-10 09:38:34.695000+0000
Victor 50 2021-04-10 09:38:39.703000+0000
Laia 40 2021-04-10 09:38:44.701000+0000
Victor 10 2021-04-10 09:38:49.711000+0000
Victor 40 2021-04-10 09:38:54.721000+0000
Laia 40 2021-04-10 09:38:59.715000+0000
Laia 50 2021-04-10 09:39:04.741000+0000
Laia 20 2021-04-10 09:39:09.867000+0000
Laia 20 2021-04-10 09:39:14.749000+0000
我的代码: window_withTrigger =(字数
| "window" >> beam.WindowInto(beam.window.FixedWindows(60),
trigger=AfterProcessingTime(1 * 10),
accumulation_mode= AccumulationMode.ACCUMULATING)
| "Group" >> GroupByKey())
window_withoutTrigger = (字数
| "window" >> beam.WindowInto(beam.window.FixedWindows(60))
| "Group" >> GroupByKey())
O/P 对于 window_withTrigger:
Laia [30]
Victor [20, 50, 10, 40]
Laia [50, 20, 20]
O/P 对于 window_withoutTrigger:
Laia [30, 40, 40]
Victor [20, 50, 10, 40]
Laia [50, 20, 20]
没有触发器的输出我得到了我发布到主题的所有 10 个元素,有触发器我得到了 8 个元素。我注意到触发器不会在 10 秒内发出结果,如果键项没有变化,即只有当 i/p 名称从 laila 更改为 victor 时它才会发出结果,一旦它发出 window 即使我使用相同的密钥发布它也不会再次发出。
您可能因为没有使用 Repeatedly
而删除了元素。
这里有另一个 Repeatedly
,触发器只会触发一次。