Skip to content

Conversation

@a10y
Copy link
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

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 2 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
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
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
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
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
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

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

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