Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/3375#discussion_r20625403
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashOuterJoin.scala
---
@@ -72,53 +72,54 @@ case class HashOuterJoin(
// iterator for performance purpose.
private[this] def leftOuterIterator(
- key: Row, leftIter: Iterable[Row], rightIter: Iterable[Row]):
Iterator[Row] = {
+ key: Row, leftRow: Row, rightIter: Iterable[Row]): Iterator[Row] = {
val joinedRow = new JoinedRow()
val rightNullRow = new GenericRow(right.output.length)
val boundCondition =
condition.map(newPredicate(_, left.output ++
right.output)).getOrElse((row: Row) => true)
- leftIter.iterator.flatMap { l =>
- joinedRow.withLeft(l)
- var matched = false
- (if (!key.anyNull) rightIter.collect { case r if
(boundCondition(joinedRow.withRight(r))) =>
- matched = true
- joinedRow.copy
- } else {
- Nil
- }) ++ DUMMY_LIST.filter(_ => !matched).map( _ => {
- // DUMMY_LIST.filter(_ => !matched) is a tricky way to add
additional row,
- // as we don't know whether we need to append it until finish
iterating all of the
- // records in right side.
- // If we didn't get any proper row, then append a single row with
empty right
- joinedRow.withRight(rightNullRow).copy
- })
- }
+ joinedRow.withLeft(leftRow)
+ var matched = false
+ val ret = (if (!key.anyNull) rightIter.collect {
+ case r if (boundCondition(joinedRow.withRight(r))) =>
+ matched = true
+ joinedRow.copy
+ } else {
+ Nil
+ }) ++ DUMMY_LIST.filter(_ => !matched).map( _ => {
--- End diff --
`DUMMY_LIST.fitler` was for easy understanding, now it will be called more
times that before, probably will be the new performance bottleneck, I can
understand if we leave that for further improvement.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]