Closed paleolimbot closed 1 year ago
At the risk of turning into a general C utilities library, I've found having a string builder utility also useful in the ADBC SQLite driver I'm working on.
I forget exactly where I did that but I definitely did it too at least once (I think I was building error messages).
Oh! It's was in nanoarrow itself but I changed approaches...it was the first draft of the ArrowSchemaToString()
.
...based on writing some nanoarrow code in the R package, https://github.com/geoarrow/geoarrow-cpp/ , and https://github.com/paleolimbot/minigpkg/
A few that may be nice are:
ArrowBufferAppendStringView()
(i.e.,ArrowBufferAppendStringView(buffer, ArrowCharView("some string");
)ArrowBufferAppendBufferView()
(i.e.,ArrowBufferAppendBufferView(buffer, some_array_view->buffer_views[1])
)ArrowArrayMove(struct ArrowArray* src, struct ArrowArray* dst)
,ArrowSchemaMove(struct ArrowSchema* src, struct ArrowSchema* dst)
, andArrowArrayStreamMove(struct ArrowArrayStream* src, struct ArrowArrayStream* dst)
(more readable thanmemcpy(dst, src, sizeof(struct ArrowSomething); src->release = NULL;
)Another thing that came up is a pattern for unsafe appends. The buffer appenders in the
ArrowBufferAppendInt32()
family all check and possibly reallocate; the array appenders in theArrowArrayAppendInt()
family do aswitch()
on type and range checks to help prevent implicit overflow. Adding more convenience around this like maybeArrowBufferAppendInt32Unsafe()
orArrowArrayInt32AppendInt32Unsafe()
is probably very verbose and isn't that hard to work around. I could be convinced either way on whether they should exist or not.