Skip to content

Commit

Permalink
close vectors when there is an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
razajafri committed Jun 18, 2021
1 parent 3f7d70b commit f9858e0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions java/src/main/java/ai/rapids/cudf/ColumnView.java
Original file line number Diff line number Diff line change
Expand Up @@ -595,14 +595,21 @@ public final ColumnVector subVector(int start, int end) {
*/
public final ColumnVector[] split(int... indices) {
ColumnView[] views = splitAsViews(indices);
ColumnVector[] columnVectors = new ColumnVector[views.length];
try {
ColumnVector[] columnVectors = new ColumnVector[views.length];
for (int i = 0; i < views.length; i++) {
columnVectors[i] = views[i].copyToColumnVector();
}
return columnVectors;
} catch (Throwable t) {
for (ColumnVector cv : columnVectors) {
if (cv != null) {
cv.close();
}
}
throw t;
} finally {
for (ColumnView view: views) {
for (ColumnView view : views) {
view.close();
}
}
Expand All @@ -613,7 +620,7 @@ public final ColumnVector[] split(int... indices) {
* according to a set of indices. No data is moved or copied.
*
* IMPORTANT NOTE: Nothing is copied out from the vector and the slices will only be relevant for
* the lifecycle of the underlying ColumnVector
* the lifecycle of the underlying ColumnVector.
*
* The "split" function divides the input column into multiple intervals
* of rows using the splits indices values and it stores the intervals into the
Expand Down

0 comments on commit f9858e0

Please sign in to comment.