Skip to content

Commit

Permalink
[SPARK-8346] [SQL] Use InternalRow instread of catalyst.InternalRow
Browse files Browse the repository at this point in the history
cc rxin marmbrus

Author: Davies Liu <davies@databricks.com>

Closes apache#6802 from davies/cleanup_internalrow and squashes the following commits:

769d2aa [Davies Liu] remove not needed cast
4acbbe4 [Davies Liu] catalyst.Internal -> InternalRow
  • Loading branch information
Davies Liu authored and nemccarthy committed Jun 19, 2015
1 parent 47deb84 commit 858058d
Show file tree
Hide file tree
Showing 22 changed files with 176 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ case class UnresolvedAttribute(nameParts: Seq[String])
override def withName(newName: String): UnresolvedAttribute = UnresolvedAttribute.quoted(newName)

// Unresolved attributes are transient at compile time and don't get evaluated during execution.
override def eval(input: catalyst.InternalRow = null): Any =
override def eval(input: InternalRow = null): Any =
throw new TreeNodeException(this, s"No function to evaluate expression. type: ${this.nodeName}")

override def toString: String = s"'$name"
Expand All @@ -86,7 +86,7 @@ case class UnresolvedFunction(name: String, children: Seq[Expression]) extends E
override lazy val resolved = false

// Unresolved functions are transient at compile time and don't get evaluated during execution.
override def eval(input: catalyst.InternalRow = null): Any =
override def eval(input: InternalRow = null): Any =
throw new TreeNodeException(this, s"No function to evaluate expression. type: ${this.nodeName}")

override def toString: String = s"'$name(${children.mkString(",")})"
Expand All @@ -108,7 +108,7 @@ trait Star extends NamedExpression with trees.LeafNode[Expression] {
override lazy val resolved = false

// Star gets expanded at runtime so we never evaluate a Star.
override def eval(input: catalyst.InternalRow = null): Any =
override def eval(input: InternalRow = null): Any =
throw new TreeNodeException(this, s"No function to evaluate expression. type: ${this.nodeName}")

def expand(input: Seq[Attribute], resolver: Resolver): Seq[NamedExpression]
Expand Down Expand Up @@ -167,7 +167,7 @@ case class MultiAlias(child: Expression, names: Seq[String])

override lazy val resolved = false

override def eval(input: catalyst.InternalRow = null): Any =
override def eval(input: InternalRow = null): Any =
throw new TreeNodeException(this, s"No function to evaluate expression. type: ${this.nodeName}")

override def toString: String = s"$child AS $names"
Expand Down Expand Up @@ -201,7 +201,7 @@ case class UnresolvedExtractValue(child: Expression, extraction: Expression)
override def nullable: Boolean = throw new UnresolvedException(this, "nullable")
override lazy val resolved = false

override def eval(input: catalyst.InternalRow = null): Any =
override def eval(input: InternalRow = null): Any =
throw new TreeNodeException(this, s"No function to evaluate expression. type: ${this.nodeName}")

override def toString: String = s"$child[$extraction]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression w
}
// TODO: Could be faster?
val newRow = new GenericMutableRow(from.fields.size)
buildCast[catalyst.InternalRow](_, row => {
buildCast[InternalRow](_, row => {
var i = 0
while (i < row.length) {
val v = row(i)
Expand Down Expand Up @@ -426,7 +426,7 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression w

private[this] lazy val cast: Any => Any = cast(child.dataType, dataType)

override def eval(input: catalyst.InternalRow): Any = {
override def eval(input: InternalRow): Any = {
val evaluated = child.eval(input)
if (evaluated == null) null else cast(evaluated)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ case class GetStructField(child: Expression, field: StructField, ordinal: Int)
override def foldable: Boolean = child.foldable
override def toString: String = s"$child.${field.name}"

override def eval(input: catalyst.InternalRow): Any = {
val baseValue = child.eval(input).asInstanceOf[catalyst.InternalRow]
override def eval(input: InternalRow): Any = {
val baseValue = child.eval(input).asInstanceOf[InternalRow]
if (baseValue == null) null else baseValue(ordinal)
}
}
Expand All @@ -125,8 +125,8 @@ case class GetArrayStructFields(
override def foldable: Boolean = child.foldable
override def toString: String = s"$child.${field.name}"

override def eval(input: catalyst.InternalRow): Any = {
val baseValue = child.eval(input).asInstanceOf[Seq[catalyst.InternalRow]]
override def eval(input: InternalRow): Any = {
val baseValue = child.eval(input).asInstanceOf[Seq[InternalRow]]
if (baseValue == null) null else {
baseValue.map { row =>
if (row == null) null else row(ordinal)
Expand All @@ -146,7 +146,7 @@ abstract class ExtractValueWithOrdinal extends ExtractValue {
override def toString: String = s"$child[$ordinal]"
override def children: Seq[Expression] = child :: ordinal :: Nil

override def eval(input: catalyst.InternalRow): Any = {
override def eval(input: InternalRow): Any = {
val value = child.eval(input)
if (value == null) {
null
Expand Down

0 comments on commit 858058d

Please sign in to comment.