Skip to content

Commit

Permalink
simplified the construction of zero scalar in GpuUnaryMinus (#4482)
Browse files Browse the repository at this point in the history
Signed-off-by: sperlingxx <lovedreamf@gmail.com>
  • Loading branch information
sperlingxx authored Jan 13, 2022
1 parent 358d97e commit 0d89e41
Showing 1 changed file with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021, NVIDIA CORPORATION.
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -73,19 +73,9 @@ case class GpuUnaryMinus(child: Expression, failOnError: Boolean) extends GpuUna
}
dataType match {
case dt: DecimalType =>
val scale = dt.scale
if (DecimalType.is32BitDecimalType(dt)) {
withResource(Scalar.fromDecimal(-scale, 0)) { scalar =>
scalar.sub(input.getBase)
}
} else if (DecimalType.is64BitDecimalType(dt)) {
withResource(Scalar.fromDecimal(-scale, 0L)) { scalar =>
scalar.sub(input.getBase)
}
} else { // Decimal-128
withResource(Scalar.fromDecimal(-scale, BigInteger.ZERO)) { scalar =>
scalar.sub(input.getBase)
}
val zeroLit = Decimal(0L, dt.precision, dt.scale)
withResource(GpuScalar.from(zeroLit, dt)) { scalar =>
scalar.sub(input.getBase)
}
case _ =>
withResource(Scalar.fromByte(0.toByte)) { scalar =>
Expand Down

0 comments on commit 0d89e41

Please sign in to comment.