vortex icon indicating copy to clipboard operation
vortex copied to clipboard

FFI API Create array

Open frederikja163 opened this issue 1 month ago • 1 comments

According to the following it should be possible to create a new vx_array with vx_array_primitive_new. However no function with that name exists. This might just be an error. Otherwise im curious about how im supposed to create new arrays when writing a vortex file using the FFI API. https://github.com/vortex-data/vortex/blob/32d083480896f402f40888898ed060a0881ac559/vortex-ffi/cinclude/vortex.h#L232-L243

frederikja163 avatar Nov 11 '25 11:11 frederikja163

Hey @frederikja163 ! Welcome!

You are correct, this function is not defined, but it should be.

We are in the midst of a rather significant change to the Vortex library (see the RFC #4726, and two of the tracking issues #4492 and #5028). Once that change settles, I think the core team should absolutely add these functions.

If you want these functions sooner than that, I think that's also reasonable though there might be some churn underneath you. The natural first thing is to define a box_wrapper for PrimitiveArray

box_wrapper!(PrimitiveArray, vx_array_primitive);

But that doesn't give you a very useful API. vx_array_primitive_new expects a Box<PrimitiveArray>. We typically construct PrimitiveArray either by way of a vortex_buffer::BufferMut or a vortex_array::builders::PrimitiveBuilder<T>. We probably also want a way to construct a BufferMut from memory allocated in C identified by, say, a pointer and a length. I don't think any of this is too complicated to write, but it's a lot of boilerplate code.

danking avatar Nov 12 '25 22:11 danking