有没有办法通过 keyBy 广播?

发布于 2025-01-12 01:01:33 字数 184 浏览 3 评论 0原文

我使用flink版本1.14.3

我有一个大数据(大约4Gb)想要广播到KeyedBroadcastProcessFunction,但是如果我将原始数据广播到每个节点,它将占用大量内存和低性能,所以我想要要知道,是否有某种方法可以在处理函数和广播中使用相同的 keySelector 规则,即 keyBy 广播然后让指定的键到达指定的节点?

i use flink version 1.14.3

i have a large data (about 4Gb) that want to broadcast to a KeyedBroadcastProcessFunction, but if i broadcast the raw data to every node, it's will take up a lot of memory and low performance, so i want to know, is there has some way to use the same keySeletor rule in process function and broadcast, that can keyBy broadcast then let the specified key goes to the specified node?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硬不硬你别怂 2025-01-19 01:01:33

广播的定义是将所有内容发送到每个下游节点。

相反,如果您有两个流,您希望将它们键分区到同一键空间中,以便您可以在该键上将它们连接起来,则可以这样做。您将使用 KeyedCoProcessFunction 而不是 KeyedBroadcastProcessFunction。看起来像这样:

DataStream<A> a = env.addSource(aSource).keyBy(a -> a.key);

DataStream<B> b = env.addSource(bSource).keyBy(b -> b.key);

a.connect(b)
    .process(new MyKeyedCoProcessFunction())
    ...

请参阅 Apache Flink 中的 RidesAndFares 练习训练以获得此模式的完整示例。

The very definition of broadcast is that everything is sent to every downstream node.

If instead, you have two streams that you want to key partition into the same key space, so that you can join them on that key, you can do that. Instead of a KeyedBroadcastProcessFunction you will use a KeyedCoProcessFunction. That looks something like this:

DataStream<A> a = env.addSource(aSource).keyBy(a -> a.key);

DataStream<B> b = env.addSource(bSource).keyBy(b -> b.key);

a.connect(b)
    .process(new MyKeyedCoProcessFunction())
    ...

See the RidesAndFares exercise from the Apache Flink training for a complete example of this pattern.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文