Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Davies Liu committed Jun 5, 2015
1 parent 12ff88a commit 2344bc0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ class CodeGenContext {
* Returns a function to generate equal expression in Java
*/
def equalFunc(dataType: DataType): ((Term, Term) => Code) = dataType match {
case BinaryType => { case (eval1, eval2) => s"java.util.Arrays.equals($eval1, $eval2)" }
case dt if isNativeType(dt) => { case (eval1, eval2) => s"$eval1 == $eval2" }
case other => { case (eval1, eval2) => s"$eval1.equals($eval2)" }
case BinaryType => { case (eval1, eval2) =>
s"java.util.Arrays.equals($eval1, $eval2)" }
case IntegerType | BooleanType | LongType | DoubleType | FloatType | ShortType | ByteType =>
{ case (eval1, eval2) => s"$eval1 == $eval2" }
case other =>
{ case (eval1, eval2) => s"$eval1.equals($eval2)" }
}

/**
Expand Down Expand Up @@ -221,7 +224,13 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
*/
protected def compile(code: String): Class[_] = {
val startTime = System.nanoTime()
val clazz = new ClassBodyEvaluator(code).getClazz()
val clazz = try {
new ClassBodyEvaluator(code).getClazz()
} catch {
case e: Exception =>
logError(s"failed to compile:\n $code", e)
throw e
}
val endTime = System.nanoTime()
def timeMs: Double = (endTime - startTime).toDouble / 1000000
logDebug(s"Code (${code.size} bytes) compiled in $timeMs ms")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ case class CombineSets(left: Expression, right: Expression) extends BinaryExpres

leftEval.code + rightEval.code + s"""
boolean ${ev.nullTerm} = false;
${htype} ${ev.primitiveTerm} = ${leftEval.primitiveTerm};
${ev.primitiveTerm}.union(${rightEval.primitiveTerm});
${htype} ${ev.primitiveTerm} = (${htype})${leftEval.primitiveTerm};
${ev.primitiveTerm}.union((${htype})${rightEval.primitiveTerm});
"""
case _ => super.genCode(ctx, ev)
}
Expand All @@ -191,9 +191,5 @@ case class CountSet(child: Expression) extends UnaryExpression {
}
}

override def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): Code = {
castOrNull(ctx, ev, c => s"$c.size().toLong()")
}

override def toString: String = s"$child.count()"
}

0 comments on commit 2344bc0

Please sign in to comment.