cocoa-xu opened a new issue, #482:
URL: https://github.com/apache/arrow-nanoarrow/issues/482
Hi, I was wondering what's the proper/most recommended way to construct a
list? Let's say I'd like to construct a list of int32 (i.e., each row is a list
of int32), something like
| Row ID | data |
|--------|------|
| 0 | [1,2,3] |
| 1 | [4,5,6] |
Here is what I'm doing for now:
```cpp
// create first row of int32, [1,2,3]
struct ArrowSchema int32_schema{};
struct ArrowArray int32_values{};
struct ArrowError arrow_error{};
ArrowSchemaInit(int32_schema);
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(int32_schema,
NANOARROW_TYPE_INT32));
NANOARROW_RETURN_NOT_OK(ArrowArrayInitFromSchema(int32_values, int32_schema,
arrow_error));
NANOARROW_RETURN_NOT_OK(ArrowArrayStartAppending(int32_values));
NANOARROW_RETURN_NOT_OK(ArrowArrayAppendInt(int32_values, 1));
NANOARROW_RETURN_NOT_OK(ArrowArrayAppendInt(int32_values, 2));
NANOARROW_RETURN_NOT_OK(ArrowArrayAppendInt(int32_values, 3));
NANOARROW_RETURN_NOT_OK(ArrowArrayFinishBuildingDefault(int32_values,
arrow_error));
// create list of int32
struct ArrowSchema schema{};
struct ArrowArray values{};
ArrowSchemaInit(schema);
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetType(schema, NANOARROW_TYPE_LIST));
NANOARROW_RETURN_NOT_OK(ArrowArrayInitFromType(values, NANOARROW_TYPE_LIST));
```
And now I'm not sure how I can properly append a list of int32 (i.e.,
`int32_values`) to `values`. Should I use low-level functions like
- ArrowArrayAllocateChildren
- ArrowArraySetValidityBitmap
- ArrowArraySetBuffer
to construct the list (`values`) myself, or am I missing something in my
code? Any suggestions/examples would be highly appreciated. :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]