This repository was archived by the owner on Oct 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
9d3335b
init tokio runtime
vustef 922008e
use macro for async ops, and reuse RT and RESULT_CB
vustef 8c5e345
async wait for batch and sync fetch of the buffer
vustef fbee1ea
Fix integration test too
vustef 4718e3c
Switch to minimal async api. next step is removing the sync method
vustef c0ae68a
use simple accessor for the current batch
vustef 7e3be0b
fix C compilation warnings
vustef 23777ce
debug log instead of warn
vustef f1b577e
cancellation
vustef dc1e9b5
cleanup error codes
vustef a510d67
todo comment
vustef b6f080f
update build to refer to remote repo
vustef dbfd232
update version
vustef 6650853
trim whitespace
vustef a769cce
.
vustef 4092b95
cargo fmt
vustef 677892d
Fix integration test
vustef b0c5f1a
julia features
vustef d88bb24
fix linker error
vustef da94376
fix integration test warnings
vustef 4a66e30
don't use default features for integration test, there's no Julia env…
vustef c2d2dca
Switch to returning batch from an async call
vustef a03ff37
remove unused bool field
vustef 92871b7
fix fmt
vustef f10d526
remove unused cbindgen
vustef 1dbb8aa
.
vustef 9044596
minor
vustef a54ec26
Merge branch 'main' of github.com:RelationalAI/iceberg_rust_ffi into …
vustef 508c3e9
Merge branch 'main' into vs-async
gbrgr ee328f4
Refactorings
gbrgr 07ee491
More PR comments
gbrgr 206d4bb
Fix free
gbrgr 19c51b8
.
gbrgr 51a026d
Remove function
gbrgr 907675d
Simplify api
gbrgr 3d240d4
Temp state
gbrgr 9106339
.
gbrgr bffe1fe
Add NULL check
gbrgr 9934fe4
Add scan builder functions
gbrgr c7d3fe8
Cleanup
gbrgr d25ff6c
.
gbrgr 91107b8
Merge branch 'vs-async' of github.com:RelationalAI/iceberg_rust_ffi i…
vustef 127f9e7
Add CLAUDE.md and symlinked AGENTS.md
vustef f6cc6fc
Remove info calls
gbrgr a47914b
Create wait function
gbrgr ad63989
Add TODO
gbrgr 5df0d5b
Merge branch 'vs-async' of github.com:RelationalAI/iceberg_rust_ffi i…
gbrgr f6f0abc
Add assertion
gbrgr 8c2188f
Test more functions
gbrgr a3a1daa
Update object_store_ffi
gbrgr 1328c6b
PR comments
gbrgr 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [target.aarch64-apple-darwin] | ||
| rustflags = ["-Clink-arg=-undefined","-Clink-arg=dynamic_lookup"] | ||
|
|
||
| [target.x86_64-apple-darwin] | ||
| rustflags = ["-Clink-arg=-undefined","-Clink-arg=dynamic_lookup"] |
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 @@ | ||
| CLAUDE.md |
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,111 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Common Development Commands | ||
|
|
||
| ### Building | ||
| - `cargo build` - Build the Rust FFI library (debug) | ||
| - `cargo build --release --no-default-features` - Build the Rust FFI library (production) | ||
| - `make build-lib` - Build the Rust library and generate C header using cbindgen | ||
| - `make build-test` - Build the C integration test (requires library). Not needed if `./run_integration_test.sh` is to be used. | ||
|
|
||
| ### Testing | ||
| - `./run_integration_test.sh` - Recommended way to run the full integration test (builds everything and runs test with colored output) locally (requires containers). | ||
| - `make all` - Build everything and run integration test (requires containers) | ||
| - `make run-containers` - Start Docker containers for S3 testing | ||
| - `make test` - Run the integration test (requires build and containers) | ||
| - `make stop-containers` - Stop Docker containers | ||
| - `cargo test` - Run Rust unit tests | ||
|
|
||
| ### Code Quality | ||
| - `cargo fmt` - Format Rust code | ||
| - `cargo clippy` - Run Rust linter | ||
| - `cargo check` - Quick check for Rust compilation errors | ||
|
|
||
| ### Cleanup | ||
| - `make clean` - Clean build artifacts (but keep target directory) | ||
| - `make clean-all` - Clean everything including target directory | ||
|
|
||
| ## Architecture Overview | ||
|
|
||
| This project provides a **Foreign Function Interface (FFI)** for Apache Iceberg, allowing C programs (and other languages through C bindings) to access Iceberg tables stored in object storage systems like S3. The majority of the infrastucture relies on object_store_ffi crate. If you don't have access to that crate's code locally, access it at this [URL](https://github.com/RelationalAI/object_store_ffi). | ||
|
|
||
| ### Key Components | ||
|
|
||
| #### Rust Library (`src/lib.rs`) | ||
| - **Core FFI Implementation**: Exposes Iceberg functionality through C-compatible functions | ||
| - **Async Runtime Integration**: Uses Tokio for async operations with object_store_ffi for callback handling. Async operations rely on `export_runtime_op!` macro, which has a sync block, which is a builder function, where all deserialization and conversion is done. Then the result of that is passed to an async block. Each parameter has to implement Send trait, in order to be passed to the async block | ||
| - **Julia Integration**: Conditional compilation features for Julia interop (`julia` feature flag) | ||
| - **Memory Management**: Safe FFI patterns with proper cleanup functions | ||
|
|
||
| #### C header (`include/iceberg_rust_ffi.h`) | ||
| - **Manual Generation**: C header is not generated right now. Whenever you make a change in the Rust library, examine whether the header should be updated. | ||
| - **C99 Compatible**: Ensures compatibility with standard C compilers | ||
| - **Response Structures**: Async operations return response structures with context for cancellation | ||
|
|
||
| #### Integration Test (`tests/integration_test.c`) | ||
| - **Dynamic Loading**: Uses `dlopen`/`dlsym` to load the Rust library at runtime | ||
| - **Async API Testing**: Tests the new async API with response structures and callbacks | ||
| - **S3 Integration**: Connects to S3 (or MinIO) to test real object storage operations | ||
|
|
||
| ### FFI Design Patterns | ||
|
|
||
| #### Async Operations with Callbacks | ||
| The FFI uses an async callback pattern where: | ||
| 1. C calls an async function with a response structure | ||
| 2. Rust spawns the operation and returns immediately | ||
| 3. When complete, Rust invokes a callback to signal completion | ||
| 4. C polls or waits for completion, then checks the response structure | ||
|
|
||
| #### Memory Management | ||
| - **Owned Pointers**: Rust allocates, C receives opaque pointers | ||
| - **Cleanup Functions**: Every allocated resource has a corresponding `_free` function | ||
| - **Error Handling**: Errors are returned via response structures with allocated error strings | ||
|
|
||
| #### Context and Cancellation | ||
| - Operations return a context pointer that can be used for cancellation | ||
| - `iceberg_cancel_context` and `iceberg_destroy_context` functions manage operation lifecycle | ||
|
|
||
| ### S3 Configuration | ||
|
|
||
| The integration test expects AWS S3 credentials through environment variables: | ||
| - `AWS_ACCESS_KEY_ID` | ||
| - `AWS_SECRET_ACCESS_KEY` | ||
| - `AWS_REGION` or `AWS_DEFAULT_REGION` | ||
| - `AWS_ENDPOINT_URL` (for MinIO or custom S3-compatible storage) | ||
|
|
||
| Use the `.env` file or export variables directly. The test is designed to fail with permission errors when S3 paths are inaccessible, which confirms the API is working correctly. | ||
|
|
||
| ### Build System | ||
|
|
||
| #### Cargo Features | ||
| - Default features: `["julia"]` | ||
| - `julia` feature: Enables Julia thread adoption and GC integration | ||
| - Integration tests use `--no-default-features` to avoid Julia dependencies | ||
|
|
||
| ### RustyIceberg.jl | ||
|
|
||
| Whenever making API changes here, the corresponding changes should be made in the RustyIceberg.jl repository, if it exists locally in the same folder next to this repository. This repository is for Julia bindings on top of this FFI. | ||
| Once changes are made there, they should be tested by: | ||
| 1. Doing `cargo build` (with default features) for the iceberg_rust_ffi. | ||
| 2. Invoking `ICEBERG_RUST_LIB=<path_to_iceberg_rust_ffi_folder>/target/debug julia --project=. examples/basic_usage.jl` in the RustyIceberg.jl directory. | ||
|
|
||
| ## Development Notes | ||
|
|
||
| ### Working with FFI | ||
| - Always check for null pointers in C code before dereferencing | ||
| - Use the provided `_free` functions to avoid memory leaks | ||
| - Error messages are allocated strings that must be freed with `iceberg_destroy_cstring` | ||
|
|
||
| ### Testing Changes | ||
| Run the integration test after making changes to verify the FFI still works: | ||
| ```bash | ||
| ./run_integration_test.sh | ||
| ``` | ||
|
|
||
| ### Object Store Integration | ||
| This crate depends on `object_store_ffi` for async runtime management and callback handling. The integration provides: | ||
| - Cross-platform async runtime setup | ||
| - Callback infrastructure for async operations | ||
| - Context management for cancellation support |
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.
Uh oh!
There was an error while loading. Please reload this page.