Skip to content

Commit

Permalink
Add codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
qiansl127 committed Jun 19, 2015
1 parent da60eb3 commit 04bd27b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.spark.sql.catalyst.expressions

import org.apache.commons.codec.digest.DigestUtils
import org.apache.spark.sql.catalyst.expressions.codegen._
import org.apache.spark.sql.types.{BinaryType, StringType, DataType}
import org.apache.spark.unsafe.types.UTF8String

Expand All @@ -41,5 +42,9 @@ case class Md5(child: Expression)
}
}

override def toString: String = s"MD5($child)"
override def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): String = {
defineCodeGen(ctx, ev, c =>
s"""org.apache.spark.unsafe.types.UTF8String.fromString
|(org.apache.commons.codec.digest.DigestUtils.md5Hex($c))""".stripMargin)
}
}

0 comments on commit 04bd27b

Please sign in to comment.