paleolimbot commented on issue #73:
URL: https://github.com/apache/arrow-nanoarrow/issues/73#issuecomment-1327967859

   Ok, that makes more sense.
   
   For producing, maybe just add a `ArrowSchemaInitUnion(schema, n_children)` 
or something that generates the `0,1,2,3,...,n_children` string and calls 
`ArrowSchemaAllocateChildren()`? For Arrays, maybe 
`ArrowArrayFinishElementUnion(array, char which_child)` (called after 
`ArrowArrayAppendSomething(array->children[which_child], ...)`)?
   
   For consuming, we could add a `int8_t* union_type_ids` field to the 
`ArrowArrayView` that is allocated for union types and is a home for the parsed 
values? (Or whatever cached lookup table is needed...I'm not sure my 
understanding of non-standard type ids is all there). And maybe a helper such 
that `ArrowArrayViewGetUnionChildId(array_view, i)` will get the correct index 
into `array_view->children[]`/`schema->children[]`?
   
   A similar helper for lists, as you suggest, would be nice for the schemas. 
Off the top of my head, maybe `ArrowSchemaInit(schema, 
NANOARROW_TYPE_(LARGE_)LIST)`  should just automatically do 
`ArrowSchemaAllocateChildren(schema, 1)` and 
`ArrowSchemaSetName(schema->children[0], "item")`? That would mean callers 
would have to remember to `ArrowSchemaInit(schema->children[0])` but that seems 
more flexible than squashing the child type down to an ID lest it be something 
like a decimal or fixed-sized binary that can't be initialized with just an ID.
   
   Perhaps `ArrowSchemaInit(schema, NANOARROW_TYPE_MAP)` could similarly 
allocate the proper child structure but make the caller do 
`ArrowSchemaInit(schema->children[0]->children[0], key_type)` and 
`ArrowSchemaInit(schema->children[0]->children[1], value_type)`? Still a little 
verbose, but more composable than just `ArrowSchemaInitMap(schema, key_type_id, 
value_type_id)`.
   
   (Also happy to do the ID-based constructors...the 4 people in the world that 
are creating recursively nested arrays in C probably won't mind the extra few 
lines it takes to do this without the convenience functions).
   


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

Reply via email to