-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Java nvcomp JNI bindings to nvcomp 2.x API (#9384)
This PR Closes #8336 The Java nvcomp JNI bindings are updated to the nvcomp 2.x API and the nvcomp library is no longer built as part of the Java build. It is reused from the dependency that libcudf is using. Note that the nvcomp 1.x API is no longer supported by the CUDF Java JNI, so this is a breaking change. Spark-Rapids currently depends on the nvcomp 1.x JNI. I will be putting up a PR for spark-rapids that changes it to use this 2.x JNI, which will need to be merged soon after this PR to minimize incompatibilities. Authors: - Jim Brennan (https://github.com/jbrennan333) Approvers: - Alessandro Bellina (https://github.com/abellina) - Jason Lowe (https://github.com/jlowe) URL: #9384
- Loading branch information
1 parent
5cd3003
commit 063c982
Showing
18 changed files
with
1,142 additions
and
1,641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright (c) 2021, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ai.rapids.cudf; | ||
|
||
/** Utility class that wraps an array of closeable instances and can be closed */ | ||
public class CloseableArray<T extends AutoCloseable> implements AutoCloseable { | ||
private T[] array; | ||
|
||
public static <T extends AutoCloseable> CloseableArray<T> wrap(T[] array) { | ||
return new CloseableArray<T>(array); | ||
} | ||
|
||
CloseableArray(T[] array) { | ||
this.array = array; | ||
} | ||
|
||
public int size() { | ||
return array.length; | ||
} | ||
|
||
public T get(int i) { | ||
return array[i]; | ||
} | ||
|
||
public T set(int i, T obj) { | ||
array[i] = obj; | ||
return obj; | ||
} | ||
|
||
public T[] getArray() { | ||
return array; | ||
} | ||
|
||
public T[] release() { | ||
T[] result = array; | ||
array = null; | ||
return result; | ||
} | ||
|
||
public void closeAt(int i) { | ||
try { | ||
T toClose = array[i]; | ||
array[i] = null; | ||
toClose.close(); | ||
} catch (RuntimeException e) { | ||
throw e; | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() { | ||
close(null); | ||
} | ||
|
||
public void close(Exception pendingError) { | ||
if (array == null) { | ||
return; | ||
} | ||
T[] toClose = array; | ||
array = null; | ||
RuntimeException error = null; | ||
if (pendingError instanceof RuntimeException) { | ||
error = (RuntimeException) pendingError; | ||
} else if (pendingError != null) { | ||
error = new RuntimeException(pendingError); | ||
} | ||
for (T obj: toClose) { | ||
if (obj != null) { | ||
try { | ||
obj.close(); | ||
} catch (RuntimeException e) { | ||
if (error != null) { | ||
error.addSuppressed(e); | ||
} else { | ||
error = e; | ||
} | ||
} catch (Exception e) { | ||
if (error != null) { | ||
error.addSuppressed(e); | ||
} else { | ||
error = new RuntimeException(e); | ||
} | ||
} | ||
} | ||
} | ||
if (error != null) { | ||
throw error; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.