Skip to content

Commit

Permalink
Remove the null replacement in computePredicate (NVIDIA#2486)
Browse files Browse the repository at this point in the history
Signed-off-by: Firestarman <firestarmanllc@gmail.com>
  • Loading branch information
firestarman authored May 24, 2021
1 parent be5dfdc commit 52327ff
Showing 1 changed file with 2 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,13 @@ import org.apache.spark.sql.types.{BooleanType, DataType}
import org.apache.spark.sql.vectorized.ColumnarBatch

abstract class GpuConditionalExpression extends ComplexTypeMergingExpression with GpuExpression {
private def computePredicate(
batch: ColumnarBatch,
predicateExpr: Expression): GpuColumnVector = {
val predicate: Any = predicateExpr.columnarEval(batch)
try {
if (!predicate.isInstanceOf[GpuColumnVector]) {
throw new IllegalStateException("Predicate result is not a column")
}
val p = predicate.asInstanceOf[GpuColumnVector]

// TODO: This null replacement is no longer necessary when
// https://github.com/rapidsai/cudf/issues/3856 is fixed.
withResource(Scalar.fromBool(false)) { falseScalar =>
GpuColumnVector.from(p.getBase.replaceNulls(falseScalar), BooleanType)
}
} finally {
predicate match {
case c: AutoCloseable => c.close()
case _ =>
}
}
}

protected def computeIfElse(
batch: ColumnarBatch,
predicateExpr: Expression,
trueExpr: Expression,
falseValues: GpuColumnVector): GpuColumnVector = {
withResource(computePredicate(batch, predicateExpr)) { predicate =>
withResource(GpuExpressionsUtils.columnarEvalToColumn(predicateExpr, batch)) { predicate =>
val trueResult: Any = trueExpr.columnarEval(batch)
try {
val result = trueResult match {
Expand All @@ -77,7 +55,7 @@ abstract class GpuConditionalExpression extends ComplexTypeMergingExpression wit
predicateExpr: Expression,
trueExpr: Expression,
falseValue: Scalar): GpuColumnVector = {
withResource(computePredicate(batch, predicateExpr)) { predicate =>
withResource(GpuExpressionsUtils.columnarEvalToColumn(predicateExpr, batch)) { predicate =>
val trueResult: Any = trueExpr.columnarEval(batch)
try {
val result = trueResult match {
Expand Down

0 comments on commit 52327ff

Please sign in to comment.