Skip to content

Refactor NIFs#156

Merged
josevalim merged 1 commit intomainfrom
jk-fine-2
Apr 5, 2026
Merged

Refactor NIFs#156
josevalim merged 1 commit intomainfrom
jk-fine-2

Conversation

@jonatanklosko
Copy link
Copy Markdown
Member

Notable changes:

  • We now use fine for encoding/decoding throughout. In particular for structs such as %Column{}, %Field{}, %BufferData{}.
  • We use exceptions to propagate errors while building/reading arrow data, instead of status returns.
  • Using nanoarrow::UniqueSchema, nanoarrow::UniqueArray for RAII memory management, which makes it easier to avoid memory leaks.
  • I removed materialization, so now we build %Adbc.Column{} with both :field and :data in a single pass. Recently we switched materialization, so that it doesn't build individual terms in the NIF, but instead we return simple structs like %BufferData{} with resource binary inside. This means that the more expensive part is not materialization, but decoding later as part of to_list.

Comment thread lib/adbc/connection.ex
Comment on lines +553 to +558
defp params_to_columns(params) when is_list(params) do
Enum.map(params, fn
%Adbc.Column{} = col -> col
param -> Adbc.Column.new([param])
end)
end
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had separate branches for when a parameter is a column or one of many primitives. By building a column here, it is all unified downstream.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is great. It may mean we don't handle all primitives yet, but that can be implemented for new in the future, so that's fine!

@josevalim josevalim merged commit 2772e37 into main Apr 5, 2026
3 checks passed
@josevalim
Copy link
Copy Markdown
Contributor

💚 💙 💜 💛 ❤️

Merging cause I want to push a tiny optimization to encode_map_32 (to split and zip at the same time).

@josevalim josevalim deleted the jk-fine-2 branch April 5, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants