From 5a4c5f36f082ad9cf1dcc6a2e48a96218ec2093d Mon Sep 17 00:00:00 2001 From: "Robert (Bobby) Evans" Date: Fri, 21 Jan 2022 13:24:33 -0600 Subject: [PATCH 1/2] Fix for appending decimal128 under list and struct types (#10105) I know that this is past the freeze date. This is a fix for a P1 bug that we just found when trying to build Scalar values of Lists and Structs that contain Decimal128 values. We might be able to work around it some other way, but it would take a lot of changes to the existing Spark plugin code to do that so I wanted to try this first. Authors: - Robert (Bobby) Evans (https://github.com/revans2) Approvers: - Kuhu Shukla (https://github.com/kuhushukla) - Niranjan Artal (https://github.com/nartal1) --- .../main/java/ai/rapids/cudf/HostColumnVector.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/java/src/main/java/ai/rapids/cudf/HostColumnVector.java b/java/src/main/java/ai/rapids/cudf/HostColumnVector.java index e21a4ac81c6..0fe7d7a5df8 100644 --- a/java/src/main/java/ai/rapids/cudf/HostColumnVector.java +++ b/java/src/main/java/ai/rapids/cudf/HostColumnVector.java @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -1136,6 +1136,8 @@ private void appendChildOrNull(ColumnBuilder childBuilder, Object listElement) { childBuilder.append((Short) listElement); } else if (listElement instanceof BigDecimal) { childBuilder.append((BigDecimal) listElement); + } else if (listElement instanceof BigInteger) { + childBuilder.append((BigInteger) listElement); } else if (listElement instanceof List) { childBuilder.append((List) listElement); } else if (listElement instanceof StructData) { @@ -1230,18 +1232,20 @@ public final ColumnBuilder append(boolean value) { return this; } - public final ColumnBuilder append(BigDecimal value) { + public ColumnBuilder append(BigDecimal value) { + return append(value.setScale(-type.getScale(), RoundingMode.UNNECESSARY).unscaledValue()); + } + + public ColumnBuilder append(BigInteger unscaledVal) { growBuffersAndRows(false, currentIndex * type.getSizeInBytes() + type.getSizeInBytes()); assert currentIndex < rows; - // Rescale input decimal with UNNECESSARY policy, which accepts no precision loss. - BigInteger unscaledVal = value.setScale(-type.getScale(), RoundingMode.UNNECESSARY).unscaledValue(); if (type.typeId == DType.DTypeEnum.DECIMAL32) { data.setInt(currentIndex * type.getSizeInBytes(), unscaledVal.intValueExact()); } else if (type.typeId == DType.DTypeEnum.DECIMAL64) { data.setLong(currentIndex * type.getSizeInBytes(), unscaledVal.longValueExact()); } else if (type.typeId == DType.DTypeEnum.DECIMAL128) { assert currentIndex < rows; - byte[] unscaledValueBytes = value.unscaledValue().toByteArray(); + byte[] unscaledValueBytes = unscaledVal.toByteArray(); byte[] result = convertDecimal128FromJavaToCudf(unscaledValueBytes); data.setBytes(currentIndex*DType.DTypeEnum.DECIMAL128.sizeInBytes, result, 0, result.length); } else { From fd968f3229ac9d3ce54ee1d3c08eddac80ba8568 Mon Sep 17 00:00:00 2001 From: Peixin Date: Mon, 24 Jan 2022 10:33:44 +0800 Subject: [PATCH 2/2] Update cudf java binding version to 22.04.0-SNAPSHOT (#10084) Signed-off-by: Peixin Li Update cudfjni version to 22.04.0-SNAPSHOT Authors: - Peixin (https://github.com/pxLi) Approvers: - Jason Lowe (https://github.com/jlowe) - Nghia Truong (https://github.com/ttnghia) URL: https://github.com/rapidsai/cudf/pull/10084 --- java/ci/README.md | 4 ++-- java/pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/java/ci/README.md b/java/ci/README.md index 0e947b62511..f022bec04e3 100644 --- a/java/ci/README.md +++ b/java/ci/README.md @@ -34,7 +34,7 @@ nvidia-docker run -it cudf-build:11.5.0-devel-centos7 bash You can download the cuDF repo in the docker container or you can mount it into the container. Here I choose to download again in the container. ```bash -git clone --recursive https://github.com/rapidsai/cudf.git -b branch-22.02 +git clone --recursive https://github.com/rapidsai/cudf.git -b branch-22.04 ``` ### Build cuDF jar with devtoolset @@ -47,5 +47,5 @@ scl enable devtoolset-9 "java/ci/build-in-docker.sh" ### The output -You can find the cuDF jar in java/target/ like cudf-22.02.0-SNAPSHOT-cuda11.jar. +You can find the cuDF jar in java/target/ like cudf-22.04.0-SNAPSHOT-cuda11.jar. diff --git a/java/pom.xml b/java/pom.xml index ec6968ca761..8f0fb1000d8 100755 --- a/java/pom.xml +++ b/java/pom.xml @@ -21,7 +21,7 @@ ai.rapids cudf - 22.02.0-SNAPSHOT + 22.04.0-SNAPSHOT cudfjni