From 8607d14c92f06a82e34c1e0f05f48b70a2bf7e46 Mon Sep 17 00:00:00 2001 From: Nghia Truong Date: Fri, 19 Jul 2024 22:01:29 -0700 Subject: [PATCH] Revert unrelated changes Signed-off-by: Nghia Truong --- .../nvidia/spark/rapids/jni/DecimalUtils.java | 59 ++++++++----------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/nvidia/spark/rapids/jni/DecimalUtils.java b/src/main/java/com/nvidia/spark/rapids/jni/DecimalUtils.java index 31650ea0fb..bd487706f5 100644 --- a/src/main/java/com/nvidia/spark/rapids/jni/DecimalUtils.java +++ b/src/main/java/com/nvidia/spark/rapids/jni/DecimalUtils.java @@ -31,16 +31,14 @@ public class DecimalUtils { * Multiply two DECIMAL128 columns together into a DECIMAL128 product rounded to the specified * scale with overflow detection. This method considers a precision greater than 38 as overflow * even if the number still fits in a 128-bit representation. - *

+ * * WARNING: This method has a bug which we match with Spark versions before 3.4.2, - * 4.0.0, 3.5.1. Consider the following example using Decimal with a precision of 38 and scale - * of 10: - * -8533444864753048107770677711.1312637916 * -12.0000000000 = 102401338377036577293248132533 - * .575166 + * 4.0.0, 3.5.1. Consider the following example using Decimal with a precision of 38 and scale of 10: + * -8533444864753048107770677711.1312637916 * -12.0000000000 = 102401338377036577293248132533.575166 * while the actual answer based on Java BigDecimal is 102401338377036577293248132533.575165 * - * @param a factor input, must match row count of the other factor input - * @param b factor input, must match row count of the other factor input + * @param a factor input, must match row count of the other factor input + * @param b factor input, must match row count of the other factor input * @param productScale scale to use for the product type * @return table containing a boolean column and a DECIMAL128 product column of the specified * scale. The boolean value will be true if an overflow was detected for that row's @@ -55,28 +53,23 @@ public static Table multiply128(ColumnView a, ColumnView b, int productScale) { * Multiply two DECIMAL128 columns together into a DECIMAL128 product rounded to the specified * scale with overflow detection. This method considers a precision greater than 38 as overflow * even if the number still fits in a 128-bit representation. - *

- * WARNING: With interimCast set to true, this method has a bug which we match with Spark - * versions before 3.4.2, - * 4.0.0, 3.5.1. Consider the following example using Decimal with a precision of 38 and scale - * of 10: - * -8533444864753048107770677711.1312637916 * -12.0000000000 = 102401338377036577293248132533 - * .575166 + * + * WARNING: With interimCast set to true, this method has a bug which we match with Spark versions before 3.4.2, + * 4.0.0, 3.5.1. Consider the following example using Decimal with a precision of 38 and scale of 10: + * -8533444864753048107770677711.1312637916 * -12.0000000000 = 102401338377036577293248132533.575166 * while the actual answer based on Java BigDecimal is 102401338377036577293248132533.575165 * - * @param a factor input, must match row count of the other factor input - * @param b factor input, must match row count of the other factor input + * @param a factor input, must match row count of the other factor input + * @param b factor input, must match row count of the other factor input * @param productScale scale to use for the product type - * @param interimCast whether to cast the result of the division to 38 precision before - * casting it again to the final - * precision + * @param interimCast whether to cast the result of the division to 38 precision before casting it again to the final + * precision * @return table containing a boolean column and a DECIMAL128 product column of the specified * scale. The boolean value will be true if an overflow was detected for that row's * DECIMAL128 product value. A null input row will result in a corresponding null output * row. */ - public static Table multiply128(ColumnView a, ColumnView b, int productScale, - boolean interimCast) { + public static Table multiply128(ColumnView a, ColumnView b, int productScale, boolean interimCast) { return new Table(multiply128(a.getNativeView(), b.getNativeView(), productScale, interimCast)); } @@ -85,8 +78,8 @@ public static Table multiply128(ColumnView a, ColumnView b, int productScale, * scale with overflow detection. This method considers a precision greater than 38 as overflow * even if the number still fits in a 128-bit representation. * - * @param a factor input, must match row count of the other factor input - * @param b factor input, must match row count of the other factor input + * @param a factor input, must match row count of the other factor input + * @param b factor input, must match row count of the other factor input * @param quotientScale scale to use for the quotient type * @return table containing a boolean column and a DECIMAL128 quotient column of the specified * scale. The boolean value will be true if an overflow was detected for that row's @@ -123,12 +116,12 @@ public static Table integerDivide128(ColumnView a, ColumnView b) { * Divide two DECIMAL128 columns and produce a DECIMAL128 remainder with overflow detection. * Example: * 451635271134476686911387864.48 % -961.110 = 775.233 - *

+ * * Generally, this will never really overflow unless in the divide by zero case. * But it will detect an overflow in any case. * - * @param a factor input, must match row count of the other factor input - * @param b factor input, must match row count of the other factor input + * @param a factor input, must match row count of the other factor input + * @param b factor input, must match row count of the other factor input * @param remainderScale scale to use for the remainder type * @return table containing a boolean column and a DECIMAL128 remainder column. * The boolean value will be true if an overflow was detected for that row's @@ -143,12 +136,12 @@ public static Table remainder128(ColumnView a, ColumnView b, int remainderScale) * Subtract two DECIMAL128 columns and produce a DECIMAL128 result rounded to the specified * scale with overflow detection. This method considers a precision greater than 38 as overflow * even if the number still fits in a 128-bit representation. - *

+ * * NOTE: This is very specific to Spark 3.4. This method is incompatible with previous versions * of Spark. We don't need this for versions prior to Spark 3.4 * - * @param a input, must match row count of the other input - * @param b input, must match row count of the other input + * @param a input, must match row count of the other input + * @param b input, must match row count of the other input * @param targetScale scale to use for the result * @return table containing a boolean column and a DECIMAL128 result column of the specified * scale. The boolean value will be true if an overflow was detected for that row's @@ -168,12 +161,12 @@ public static Table subtract128(ColumnView a, ColumnView b, int targetScale) { * Add two DECIMAL128 columns and produce a DECIMAL128 result rounded to the specified * scale with overflow detection. This method considers a precision greater than 38 as overflow * even if the number still fits in a 128-bit representation. - *

+ * * NOTE: This is very specific to Spark 3.4. This method is incompatible with previous versions * of Spark. We don't need this for versions prior to Spark 3.4 * - * @param a input, must match row count of the other input - * @param b input, must match row count of the other input + * @param a input, must match row count of the other input + * @param b input, must match row count of the other input * @param targetScale scale to use for the sum * @return table containing a boolean column and a DECIMAL128 sum column of the specified * scale. The boolean value will be true if an overflow was detected for that row's @@ -207,7 +200,7 @@ public CastFloatToDecimalResult(ColumnVector result, boolean hasFailure) { /** * Cast floating point values to decimals, matching the behavior of Spark. * - * @param input The input column, which is either FLOAT32 or FLOAT64 + * @param input The input column, which is either FLOAT32 or FLOAT64 * @param outputType The output decimal type * @return The decimal column resulting from the cast operation and a boolean column indicating * whether the cast operation has failed for any input rows