Skip to content

Implement missing FFI functions for array writing#5304

Closed
a10y wants to merge 1 commit intodevelopfrom
claude/implement-ffi-array-functions-011CV4jXTtBLNg5rg5KzuCku
Closed

Implement missing FFI functions for array writing#5304
a10y wants to merge 1 commit intodevelopfrom
claude/implement-ffi-array-functions-011CV4jXTtBLNg5rg5KzuCku

Conversation

@a10y
Copy link
Copy Markdown
Contributor

@a10y a10y commented Nov 12, 2025

Implements FFI builder functions for creating various Vortex array types:

  • Primitive arrays: Support for all primitive types (u8, u16, u32, u64, i8, i16, i32, i64, f16, f32, f64) with optional validity masks
  • Bool arrays: Boolean array creation with validity support
  • Decimal arrays: Decimal128 array creation with precision and scale
  • Null arrays: Simple null array construction
  • UTF8/Binary arrays: Builder-pattern API for variable-length string and binary data
  • Struct arrays: Construction from field arrays and struct dtype

Adds write-vortex.c example demonstrating:

  • Creating arrays of different types using the new builder APIs
  • Building complex struct arrays with multiple fields
  • Writing arrays to Vortex files using the sink API
  • Proper resource management and error handling

Resolves #5275

Implements FFI builder functions for creating various Vortex array types:

- **Primitive arrays**: Support for all primitive types (u8, u16, u32, u64,
  i8, i16, i32, i64, f16, f32, f64) with optional validity masks
- **Bool arrays**: Boolean array creation with validity support
- **Decimal arrays**: Decimal128 array creation with precision and scale
- **Null arrays**: Simple null array construction
- **UTF8/Binary arrays**: Builder-pattern API for variable-length string
  and binary data
- **Struct arrays**: Construction from field arrays and struct dtype

Adds `write-vortex.c` example demonstrating:
- Creating arrays of different types using the new builder APIs
- Building complex struct arrays with multiple fields
- Writing arrays to Vortex files using the sink API
- Proper resource management and error handling

Resolves #5275
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 12, 2025

Codecov Report

❌ Patch coverage is 56.90377% with 103 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.76%. Comparing base (f7dcd01) to head (87e7c21).
⚠️ Report is 1294 commits behind head on develop.

Files with missing lines Patch % Lines
vortex-ffi/src/array_builder.rs 56.90% 103 Missing ⚠️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

printf("Creating i32 array (ages)...\n");
int32_t ages_data[] = {25, 30, 35, 40, 45};
bool ages_validity[] = {true, true, false, true, true}; // 3rd value is null
size_t row_count = sizeof(ages_data) / sizeof(ages_data[0]);
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.

I wasn't aware you could sizeof an expression! Does it have to be a valid index? does sizeof ages_data[10] work?

data: *const bool,
len: usize,
validity: *const bool,
error_out: *mut *mut vx_error,
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.

the need for this has to be my least favorite part of C


for (i, &value) in data_slice.iter().enumerate() {
if !validity.is_null() {
let validity_slice = unsafe { slice::from_raw_parts(validity, len) };
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.

Is this free? It seems at least for legibility's sake, we should lift it maybe to line 101?

Copy link
Copy Markdown
Contributor

@danking danking Nov 13, 2025

Choose a reason for hiding this comment

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

ohhhhhhh ass, right, pointers. Can we switch on null-ness here and have two loops? That avoids the branch in the loop in the non-null case.

@a10y
Copy link
Copy Markdown
Contributor Author

a10y commented Nov 13, 2025

This was fully Claude-coded and has not yet been reviewed by me, I'll invest some time in this today to hopefully get it ready to be a real PR

@frederikja163
Copy link
Copy Markdown

This PR is still missing the header file declarations for cinlude.

@github-actions
Copy link
Copy Markdown
Contributor

This PR has been marked as stale because it has been open for 30 days with no activity. Please comment or remove the stale label if you wish to keep it active, otherwise it will be closed in 7 days

@github-actions github-actions bot added stale This PR is stale and will be auto-closed soon and removed stale This PR is stale and will be auto-closed soon labels Jan 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR has been marked as stale because it has been open for 30 days with no activity. Please comment or remove the stale label if you wish to keep it active, otherwise it will be closed in 7 days

@github-actions github-actions bot added stale This PR is stale and will be auto-closed soon and removed stale This PR is stale and will be auto-closed soon labels Feb 15, 2026
@AdamGS AdamGS added the stale This PR is stale and will be auto-closed soon label Mar 11, 2026
@github-actions github-actions bot removed the stale This PR is stale and will be auto-closed soon label Mar 12, 2026
@a10y a10y closed this Apr 3, 2026
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.

FFI API Create array

5 participants