-
Notifications
You must be signed in to change notification settings - Fork 27
PECOBLR-1121 Arrow patch to circumvent Arrow issues with JDk 16+. #1156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tejassp-db
wants to merge
9
commits into
main
Choose a base branch
from
PECOBLR-1121/arrow-patch/stack-0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,134
−3
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
37d7d15
PECOBLR-1121 Patch Arrow to circumvent JVM args issue.
tejassp-db ffd6c1c
PECOBLR-1121 Use Arrow patch as fallback.
tejassp-db a78a597
PECOBLR-1121 Simplify patch code.
tejassp-db 1654f74
PECOBLR-1121 Minor refactor.
tejassp-db 42422f1
PECOBLR-1121 Fix todos and fixmes.
tejassp-db 36c2d3d
PECOBLR-1121 Fix derive buffer
tejassp-db dcdc49a
PECOBLR-1121 Patch DecimalUtility.
tejassp-db 7c44728
PECOBLR-1121 Add Apache 2 compliant changes.
tejassp-db 44271f9
PECOBLR-1121 Suppress stack trace print on Arrow class init failure.
tejassp-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
56 changes: 56 additions & 0 deletions
56
src/main/java/com/databricks/jdbc/api/impl/arrow/ArrowBufferAllocator.java
This file contains hidden or 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,56 @@ | ||
| package com.databricks.jdbc.api.impl.arrow; | ||
|
|
||
| import com.databricks.jdbc.log.JdbcLogger; | ||
| import com.databricks.jdbc.log.JdbcLoggerFactory; | ||
| import org.apache.arrow.memory.BufferAllocator; | ||
| import org.apache.arrow.memory.DatabricksBufferAllocator; | ||
| import org.apache.arrow.memory.RootAllocator; | ||
|
|
||
| /** | ||
| * Creates {@link BufferAllocator} instances. | ||
| * | ||
| * <p>First tries to create a {@link RootAllocator} which uses off-heap memory and is faster. If | ||
| * that fails (usually due to JVM reflection restrictions), falls back to {@link | ||
| * DatabricksBufferAllocator} which uses heap memory. | ||
| */ | ||
| public class ArrowBufferAllocator { | ||
| /** Can a {@code RootAllocator} be created in this JVM instance? */ | ||
| private static final boolean canCreateRootAllocator; | ||
|
|
||
| /** Logger instance. */ | ||
| private static final JdbcLogger LOGGER = JdbcLoggerFactory.getLogger(ArrowBufferAllocator.class); | ||
|
|
||
| /* Check if the RootAllocator can be instantiated. */ | ||
| static { | ||
| RootAllocator rootAllocator = null; | ||
| try { | ||
| rootAllocator = new RootAllocator(); | ||
| } catch (Throwable t) { | ||
| LOGGER.info( | ||
| "Failed to create RootAllocator, will use DatabricksBufferAllocator as fallback: " | ||
| + t.getMessage()); | ||
| } | ||
|
|
||
| canCreateRootAllocator = rootAllocator != null; | ||
| if (rootAllocator != null) { | ||
| try { | ||
| rootAllocator.close(); | ||
| } catch (Throwable t) { | ||
| LOGGER.warn("RootAllocator could not be closed: " + t.getMessage()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @return an instance of the {@code BufferAllocator}. | ||
| */ | ||
| public static BufferAllocator getBufferAllocator() { | ||
| // TODO reuse RootAllocators? | ||
| // TODO should this method be non-static. | ||
| if (canCreateRootAllocator) { | ||
| return new RootAllocator(); | ||
| } else { | ||
| return new DatabricksBufferAllocator(); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we were using Integer.MAX_VALUE, not needed now?