ApacheSpark中的requiredChildDistribution和outputPartitioning有什么区别?
创始人
2024-09-06 12:30:19
0

requiredChildDistribution和outputPartitioning都是Spark中的重要概念,但在功能和用法上有所区别。

requiredChildDistribution用于指定子节点之间的数据分布方式,用法如下:

case class MyOperator(
  left: SparkPlan,
  right: SparkPlan,
  **requiredChildDistribution: Seq[Distribution]**
) extends BinaryNode {

  override def output: Seq[Attribute] = left.output ++ right.output

  override def leftChild: SparkPlan = left

  override def rightChild: SparkPlan = right

  override def requiredChildDistribution: Seq[Distribution] = Seq(UnspecifiedDistribution, UnspecifiedDistribution)

  override def doExecute(): RDD[InternalRow] = {
    ...
  }
}

其中,requiredChildDistribution是一个Seq类型的参数,表示子节点之间的数据分布方式,默认值为UnspecifiedDistribution。若想指定子节点之间的数据分布方式,也可以使用其他的分布方式,例如:

case class MyOperator(
  left: SparkPlan,
  right: SparkPlan,
  **requiredChildDistribution: Seq[Distribution]**
) extends BinaryNode {

  override def output: Seq[Attribute] = left.output ++ right.output

  override def leftChild: SparkPlan = left

  override def rightChild: SparkPlan = right

  override def requiredChildDistribution: Seq[Distribution] = Seq(ClusteredDistribution(Seq("key")), ClusteredDistribution(Seq("key")))

  override def doExecute(): RDD[InternalRow] = {
    ...
  }
}

outputPartitioning用于指定输出RDD的分区方式,用法如下:

case class MyOperator(
  child: SparkPlan,
  **outputPartitioning: Partitioning**
) extends UnaryNode {

  override def output: Seq[Attribute] = child.output

  override def child: SparkPlan = child

  override def outputPartitioning: Partitioning = HashPartitioning(Seq("key"), 10)

  override def doExecute(): RDD[InternalRow] = {
    ...
  }
}

其中,outputPartitioning是一个Partitioning类型的参数,表示输出

相关内容

热门资讯

透明私人局!德州ai辅助(微扑... 1、透明私人局!德州ai辅助(微扑克线上)竟然是真的有挂(透视)扑克教程(有挂分析)-哔哩哔哩。2、...
透明规律(wpk德州)外挂辅助... 《透明规律(wpk德州)外挂辅助脚本(辅助挂)的确真的有挂(2020已更新)(哔哩哔哩)》 wpk德...
我来教教你(德扑输赢)外挂透明... 我来教教你(德扑输赢)外挂透明挂辅助插件(辅助透视)详细教程((2021已更新))(哔哩哔哩);最新...
透视安卓版!德州ai智能营销系... 透视安卓版!德州ai智能营销系统(辅助挂)其实真的有挂(详细教程)(有挂了解)-哔哩哔哩;小薇(透视...
重大来袭!线上德州辅助工具有哪... 自定义德州ai智能系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,不管你是...
透视游戏(红龙软件德州扑克)外... 透视游戏(红龙软件德州扑克)外挂辅助机制(辅助挂)其实真的有挂(2022已更新)(哔哩哔哩);玩家必...
实测交流(线上德州aapoke... 实测交流(线上德州aapoker)外挂透明挂辅助APP(辅助透视)详细教程((2024已更新))(哔...
查到实测辅助!智星德州菠萝有挂... 查到实测辅助!智星德州菠萝有挂(透视)竟然是真的有挂(详细教程)(有挂透明)-哔哩哔哩是由北京得智星...
总算了解!gg扑克发牌问题(W... 总算了解!gg扑克发牌问题(WepOke)果真真的有挂(透视)德州论坛(有挂技术)-哔哩哔哩;gg扑...
三分钟了解(德扑之星专业)外挂... 三分钟了解(德扑之星专业)外挂透明挂辅助APP(透视辅助)详细教程((2020已更新))(哔哩哔哩)...