gpt4 book ai didi

scala - 两个分区数据帧之间的 Spark 共置连接

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

对于以下两个 DataFrames 之间的连接在 Spark 1.6.0 中

val df0Rep = df0.repartition(32, col("a")).cache
val df1Rep = df1.repartition(32, col("a")).cache
val dfJoin = df0Rep.join(df1Rep, "a")
println(dfJoin.count)

这是否不仅共同分区而且共同定位?我知道对于 RDD,如果使用相同的分区器并在相同的操作中混洗,则连接将位于同一位置。但是数据帧呢?谢谢你。

最佳答案

[ https://medium.com/@achilleus/https-medium-com-joins-in-apache-spark-part-3-1d40c1e51e1c]

根据上面提供的文章链接Sort-Merge join是默认的join,想补充一点

For Ideal performance of Sort-Merge join, it is important that all rows having the same value for the join key are available in the same partition. This warrants for the infamous partition exchange(shuffle) between executors. Collocated partitions can avoid unnecessary data shuffle. Data needs to be evenly distributed n the join keys. The number of join keys is unique enough so that they can be equally distributed across the cluster to achieve the max parallelism from the available partitions

关于scala - 两个分区数据帧之间的 Spark 共置连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42985178/

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