返回介绍

任务链和资源组

发布于 2025-05-02 18:19:14 字数 2271 浏览 0 评论 0 收藏

链接两个后续转换意味着将它们共同定位在同一个线程中以获得更好的性能。如果可能的话,Flink 默认链算子(例如,两个后续的映射转换)。如果需要,API 可以对链接进行细粒度控制:

使用 StreamExecutionEnvironment.disableOperatorChaining() 如果要禁用整个工作链。对于更细粒度的控制,可以使用以下函数。请注意,这些函数只能在 DataStream 转换后立即使用,因为它们引用了前一个转换。例如,您可以使用 someStream.map(...).startNewChain() ,但不能使用 someStream.startNewChain()

资源组是 Flink 中的一个插槽,请参阅 插槽 。如果需要,您可以在单独的插槽中手动隔离算子


转换:开始新的链条

描述:从这个 算子开始,开始一个新的链。两个映射器将被链接,并且过滤器将不会链接到第一个映射器。

someStream.filter(...).map(...).startNewChain().map(...);

转换:禁用链接

描述:不要链接 Map 算子

someStream.map(...).disableChaining();

转换:设置插槽共享组

描述:设置 算子操作的插槽共享组。Flink 将把具有相同插槽共享组的 算子操作放入同一个插槽,同时保持其他插槽中没有插槽共享组的 算子操作。这可用于隔离插槽。如果所有输入 算子操作都在同一个插槽共享组中,则插槽共享组将继承输入 算子操作。默认插槽共享组的名称为“default”,可以通过调用 slotSharingGroup(“default”)将 算子操作显式放入此组中。

someStream.filter(...).slotSharingGroup("name");

转换:Start new chain

描述:Begin a new chain, starting with this operator. The two mappers will be chained, and filter will not be chained to the first mapper.

someStream.filter(...).map(...).startNewChain().map(...)

转换:Disable chaining

描述:Do not chain the map operator

someStream.map(...).disableChaining()

转换:Set slot sharing group

描述:Set the slot sharing group of an operation. Flink will put operations with the same slot sharing group into the same slot while keeping operations that don't have the slot sharing group in other slots. This can be used to isolate slots. The slot sharing group is inherited from input operations if all input operations are in the same slot sharing group. The name of the default slot sharing group is "default", operations can explicitly be put into this group by calling slotSharingGroup("default").

someStream.filter(...).slotSharingGroup("name")

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。