Skip to content

Commit

Permalink
Remove last use of convertToScala().
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshRosen committed May 29, 2015
1 parent ae3278d commit 9c0e4e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,6 @@ object CatalystTypeConverters {
case other => other
}

/**
* Converts Catalyst types used internally in rows to standard Scala types
* This method is slow, and for batch conversion you should be using converter
* produced by createToScalaConverter.
*/
def convertToScala(catalystValue: Any, dataType: DataType): Any = {
getConverterForType(dataType).toScala(catalystValue)
}

/**
* Creates a converter function that will convert Catalyst types to Scala type.
* Typical use case would be converting a collection of rows that have the same schema. You will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ case class UserDefinedGenerator(
children: Seq[Expression])
extends Generator {

private[this] val inputRow: InterpretedProjection = new InterpretedProjection(children)
private[this] val convertToScala: (Row) => Row = {
val inputSchema = StructType(children.map(e => StructField(e.simpleString, e.dataType, true)))
CatalystTypeConverters.createToScalaConverter(inputSchema)
}.asInstanceOf[(Row => Row)]

override def eval(input: Row): TraversableOnce[Row] = {
// TODO(davies): improve this
// Convert the objects into Scala Type before calling function, we need schema to support UDT
val inputSchema = StructType(children.map(e => StructField(e.simpleString, e.dataType, true)))
val inputRow = new InterpretedProjection(children)
function(CatalystTypeConverters.convertToScala(inputRow(input), inputSchema).asInstanceOf[Row])
function(convertToScala(inputRow(input)))
}

override def toString: String = s"UserDefinedGenerator(${children.mkString(",")})"
Expand Down

0 comments on commit 9c0e4e1

Please sign in to comment.