Cache CAPIType values - #790
Merged
Merged
Conversation
staticlibs
approved these changes
Aug 7, 2026
staticlibs
left a comment
Member
There was a problem hiding this comment.
Thanks for the PR! Looks good to me. I'll add it to 1.5 branch and will publish a snapshot shortly.
staticlibs
pushed a commit
that referenced
this pull request
Aug 7, 2026
This is a backport of the PR #790 to `v1.5-variegata` stable branch.
Member
|
Snapshot with this change was published, compatible with DuckDB 1.5.5: <dependency>
<groupId>org.duckdb</groupId>
<artifactId>duckdb_jdbc</artifactId>
<version>1.5.5.2-dev-651bc51</version>
</dependency><repository>
<id>duckdb</id>
<url>https://duckdb-staging.duckdb.org/duckdb/duckdb-java/maven/</url>
</repository> |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
CAPIType.capiTypeFromTypeId()calledCAPIType.values()on every invocation, which allocates a fresh array copy of all enum constants each time. For a hot path (type resolution on every vector/column read) this creates unnecessary heap allocations and linear scan overhead.The fix introduces a
BY_TYPE_IDstatic array built once during class initialization by iteratingvalues()a single time. Lookups are now a bounds check plus a single array dereference (O(1) with no allocation, compared to the previous O(n) scan with a transient array allocation per call).