comphead commented on code in PR #4509:
URL: https://github.com/apache/datafusion-comet/pull/4509#discussion_r3405441060
##########
spark/src/main/scala/org/apache/comet/rules/CometExecRule.scala:
##########
@@ -701,21 +701,37 @@ case class CometExecRule(session: SparkSession)
}
val builder = OperatorOuterClass.Operator.newBuilder().setPlanId(op.id)
- if (op.children.nonEmpty &&
op.children.forall(_.isInstanceOf[CometNativeExec])) {
- val childOp = op.children.map(_.asInstanceOf[CometNativeExec].nativeOp)
- childOp.foreach(builder.addChildren)
- return serde
- .convert(op, builder, childOp: _*)
- .map(nativeOp => serde.createExec(nativeOp, op))
- } else {
- return serde
- .convert(op, builder)
- .map(nativeOp => serde.createExec(nativeOp, op))
+ val nativeOpOpt =
+ if (op.children.nonEmpty &&
op.children.forall(_.isInstanceOf[CometNativeExec])) {
+ val childOp =
op.children.map(_.asInstanceOf[CometNativeExec].nativeOp)
+ childOp.foreach(builder.addChildren)
+ serde.convert(op, builder, childOp: _*)
+ } else {
+ serde.convert(op, builder)
+ }
+ return nativeOpOpt.map { nativeOp =>
+ val exec = serde.createExec(nativeOp, op)
+ rollUpInfoMessages(op, exec)
+ exec
Review Comment:
I have some feeling we can avoid checkcast for all and then cast all, with
something like
```
val nativeChildren = op.children.iterator.map {
case child: CometNativeExec => child.nativeOp
}.toSeq
val nativeOpOpt =
if (nativeChildren.size == op.children.size) {
nativeChildren.foreach(builder.addChildren)
serde.convert(op, builder, nativeChildren: _*)
} else {
serde.convert(op, builder)
}
nativeOpOpt.map { nativeOp =>
val exec = serde.createExec(nativeOp, op)
rollUpInfoMessages(op, exec)
exec
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]