Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
.build(
new CacheLoader[InType, OutType]() {
override def load(in: InType): OutType = globalLock.synchronized {
create(in)
val startTime = System.nanoTime()
val result = create(in)
val endTime = System.nanoTime()
def timeMs = (endTime - startTime).toDouble / 1000000
logInfo(s"Code generated expression $in in $timeMs ms")
result
}
})

Expand Down Expand Up @@ -413,7 +418,19 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
""".children
}

EvaluatedExpression(code, nullTerm, primitiveTerm, objectTerm)
// Only inject debugging code if debugging is turned on.
val debugCode =
if (log.isDebugEnabled) {
val localLogger = log
val localLoggerTree = reify { localLogger }
q"""
$localLoggerTree.debug(${e.toString} + ": " + (if($nullTerm) "null" else $primitiveTerm))
""" :: Nil
} else {
Nil
}

EvaluatedExpression(code ++ debugCode, nullTerm, primitiveTerm, objectTerm)
}

protected def getColumn(inputRow: TermName, dataType: DataType, ordinal: Int) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ case class IsNull(child: Expression) extends Predicate with trees.UnaryNode[Expr
override def eval(input: Row): Any = {
child.eval(input) == null
}

override def toString = s"IS NULL $child"
}

case class IsNotNull(child: Expression) extends Predicate with trees.UnaryNode[Expression] {
Expand Down