From 33f7f0d032728494dcb9bb69eea96bfdc889084d Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Wed, 5 Jan 2022 15:15:43 -0600 Subject: [PATCH] Fix regression HostColumnVectorCore requiring native libs (#9948) #9485 regressed the fix in #9332. This restores the fix. It also eliminates the problematic `ColumnVector.closeBuffers` which, despite the plurality in the name, only closed one buffer and had dubious utility in converting throwables into runtime exceptions. Authors: - Jason Lowe (https://github.com/jlowe) Approvers: - Alessandro Bellina (https://github.com/abellina) - Robert (Bobby) Evans (https://github.com/revans2) - Gera Shegalov (https://github.com/gerashegalov) URL: https://github.com/rapidsai/cudf/pull/9948 --- .../java/ai/rapids/cudf/ColumnVector.java | 36 ++++++------------- .../ai/rapids/cudf/HostColumnVectorCore.java | 12 +++++-- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/java/src/main/java/ai/rapids/cudf/ColumnVector.java b/java/src/main/java/ai/rapids/cudf/ColumnVector.java index d1c3777f2c4..61981b34615 100644 --- a/java/src/main/java/ai/rapids/cudf/ColumnVector.java +++ b/java/src/main/java/ai/rapids/cudf/ColumnVector.java @@ -907,24 +907,6 @@ private static native long stringConcatenationSepCol(long[] columnViews, // INTERNAL/NATIVE ACCESS ///////////////////////////////////////////////////////////////////////////// - /** - * Close all non-null buffers. Exceptions that occur during the process will - * be aggregated into a single exception thrown at the end. - */ - static void closeBuffers(AutoCloseable buffer) { - Throwable toThrow = null; - if (buffer != null) { - try { - buffer.close(); - } catch (Throwable t) { - toThrow = t; - } - } - if (toThrow != null) { - throw new RuntimeException(toThrow); - } - } - //////// // Native methods specific to cudf::column. These either take or create a cudf::column // instead of a cudf::column_view so they need to be used with caution. These should @@ -1114,13 +1096,17 @@ protected synchronized boolean cleanImpl(boolean logErrorIfNotClean) { if (!toClose.isEmpty()) { try { for (MemoryBuffer toCloseBuff : toClose) { - closeBuffers(toCloseBuff); - } - } catch (Throwable t) { - if (toThrow != null) { - toThrow.addSuppressed(t); - } else { - toThrow = t; + if (toCloseBuff != null) { + try { + toCloseBuff.close(); + } catch (Throwable t) { + if (toThrow != null) { + toThrow.addSuppressed(t); + } else { + toThrow = t; + } + } + } } } finally { toClose.clear(); diff --git a/java/src/main/java/ai/rapids/cudf/HostColumnVectorCore.java b/java/src/main/java/ai/rapids/cudf/HostColumnVectorCore.java index dd07df16553..763ecc763a5 100644 --- a/java/src/main/java/ai/rapids/cudf/HostColumnVectorCore.java +++ b/java/src/main/java/ai/rapids/cudf/HostColumnVectorCore.java @@ -594,9 +594,15 @@ protected synchronized boolean cleanImpl(boolean logErrorIfNotClean) { boolean neededCleanup = false; if (data != null || valid != null || offsets != null) { try { - ColumnVector.closeBuffers(data); - ColumnVector.closeBuffers(offsets); - ColumnVector.closeBuffers(valid); + if (data != null) { + data.close(); + } + if (offsets != null) { + offsets.close(); + } + if (valid != null) { + valid.close(); + } } finally { // Always mark the resource as freed even if an exception is thrown. // We cannot know how far it progressed before the exception, and