Skip to content

Commit

Permalink
Ensure JNI native libraries load when CompiledExpression loads (#8997)
Browse files Browse the repository at this point in the history
`CompiledExpression` was missing a static block to ensure the native libraries were loaded before the class becomes available for use. This could result in exceptions like the following if no other cudf class with native dependencies is used first in an application:
```
java.lang.UnsatisfiedLinkError: ai.rapids.cudf.ast.CompiledExpression.compile([B)J
  at ai.rapids.cudf.ast.CompiledExpression.compile(Native Method)
  at ai.rapids.cudf.ast.CompiledExpression.<init>(CompiledExpression.java:65)
  at ai.rapids.cudf.ast.Expression.compile(Expression.java:29)
```

Authors:
  - Jason Lowe (https://github.com/jlowe)

Approvers:
  - Robert (Bobby) Evans (https://github.com/revans2)

URL: #8997
  • Loading branch information
jlowe authored Aug 9, 2021
1 parent a4eabf0 commit ed84e44
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions java/src/main/java/ai/rapids/cudf/ast/CompiledExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@

import ai.rapids.cudf.ColumnVector;
import ai.rapids.cudf.MemoryCleaner;
import ai.rapids.cudf.NativeDepsLoader;
import ai.rapids.cudf.Table;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** This class wraps a native compiled AST and must be closed to avoid native memory leaks. */
public class CompiledExpression implements AutoCloseable {
static {
NativeDepsLoader.loadNativeDeps();
}

private static final Logger log = LoggerFactory.getLogger(CompiledExpression.class);

private static class CompiledExpressionCleaner extends MemoryCleaner.Cleaner {
Expand Down

0 comments on commit ed84e44

Please sign in to comment.