diff options
author | Cheng Hao <hao.cheng@intel.com> | 2014-06-24 19:07:02 -0700 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2014-06-24 19:07:22 -0700 |
commit | c3ebf8ee680df43decbcce122c5203c27e8a75fa (patch) | |
tree | 5ff3b1f601d6da034ca8a891f5559a006e03debd | |
parent | 05f84e28f58c4bfdb6625d095aa04d6da3ef2c51 (diff) | |
download | spark-c3ebf8ee680df43decbcce122c5203c27e8a75fa.tar.gz spark-c3ebf8ee680df43decbcce122c5203c27e8a75fa.tar.bz2 spark-c3ebf8ee680df43decbcce122c5203c27e8a75fa.zip |
[SQL]Add base row updating methods for JoinedRow
This will be helpful in join operators.
Author: Cheng Hao <hao.cheng@intel.com>
Closes #1187 from chenghao-intel/joinedRow and squashes the following commits:
87c19e3 [Cheng Hao] Add base row set methods for JoinedRow
(cherry picked from commit 133495d82672c3f34d40a6298cc80c31f91faf5c)
Signed-off-by: Michael Armbrust <michael@databricks.com>
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Projection.scala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Projection.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Projection.scala index c9b7cea6a3..a9e976c3ab 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Projection.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Projection.scala @@ -81,6 +81,18 @@ class JoinedRow extends Row { this } + /** Updates this JoinedRow by updating its left base row. Returns itself. */ + def withLeft(newLeft: Row): Row = { + row1 = newLeft + this + } + + /** Updates this JoinedRow by updating its right base row. Returns itself. */ + def withRight(newRight: Row): Row = { + row2 = newRight + this + } + def iterator = row1.iterator ++ row2.iterator def length = row1.length + row2.length @@ -124,4 +136,9 @@ class JoinedRow extends Row { } new GenericRow(copiedValues) } + + override def toString() = { + val row = (if (row1 != null) row1 else Seq[Any]()) ++ (if (row2 != null) row2 else Seq[Any]()) + s"[${row.mkString(",")}]" + } } |