Open paleolimbot opened 2 years ago
Maybe Init
could take the type and then it would know how many buffers to allocate? (Ditto for AllocateChildren
)
Ah that makes sense, and parallels ArrowSchemaInit()
(where the caller can fall back on NANOARROW_TYPE_UNINITIALIZED
if they're implementing their own logic). I think ArrowArrayAllocateChildren()
has to exist on its own, but the utility of a helper like ArrowArrayInitFromSchemaView(struct ArrowArray* array, struct ArrowSchemaView* view, struct ArrowError* error)
might become clear at some point (since the schema view contains all the information needed to initialize all the buffers for all the recursive children).
Now that we have buffer holders (
struct ArrowBuffer
) we can implement an owningstruct ArrowArray
. I envision the API something like theArrowSchema*
helpers:ArrowArrayInit(struct ArrowArray* array, int64_t n_buffers)
ArrowArrayAllocateChildren(struct ArrowArray* array, int64_t n_children)
ArrowArraySetBuffer(struct ArrowArray* array, int64_t i, struct ArrowBuffer* buffer)
(moves thestruct ArrowBuffer
so that it lives in memory owned byarray->private_data
and setsarray->buffers[i] = buffer->data
).