MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / createStructArray

Function createStructArray

test/include/arrow_test_utils.h:576–609  ·  view source on GitHub ↗

Build a struct ArrowArray whose children are filled by the given builders.

Source from the content-addressed store, hash-verified

574
575// Build a struct ArrowArray whose children are filled by the given builders.
576inline ArrowArrayWrapper createStructArray(int64_t length,
577 const std::vector<std::function<void(ArrowArray*)>>& childBuilders) {
578 ArrowArrayWrapper array;
579 array.length = length;
580 array.null_count = 0;
581 array.offset = 0;
582 array.n_buffers = 1;
583 array.n_children = static_cast<int64_t>(childBuilders.size());
584 array.buffers = static_cast<const void**>(malloc(sizeof(void*)));
585 array.buffers[0] = nullptr;
586 array.children = static_cast<ArrowArray**>(malloc(sizeof(ArrowArray*) * childBuilders.size()));
587 for (size_t i = 0; i < childBuilders.size(); ++i) {
588 array.children[i] = static_cast<ArrowArray*>(malloc(sizeof(ArrowArray)));
589 childBuilders[i](array.children[i]);
590 }
591 array.dictionary = nullptr;
592 array.release = [](ArrowArray* arr) {
593 if (arr->children) {
594 for (int64_t i = 0; i < arr->n_children; ++i) {
595 if (arr->children[i]->release) {
596 arr->children[i]->release(arr->children[i]);
597 }
598 free(arr->children[i]);
599 }
600 free(arr->children);
601 }
602 if (arr->buffers) {
603 free(const_cast<void**>(arr->buffers));
604 }
605 arr->release = nullptr;
606 };
607 array.private_data = nullptr;
608 return array;
609}

Callers 15

makeSimplePersonArraysFunction · 0.85
makeSimpleCsrIndicesFunction · 0.85
makeSimpleCsrIndptrFunction · 0.85
makeIndptrBatchFunction · 0.85
TEST_FFunction · 0.85
makeUserBatchFunction · 0.85
makeCityBatchFunction · 0.85
makeFollowsBatchFunction · 0.85
makeLivesInBatchFunction · 0.85
createUserTableMethod · 0.85
createCityTableMethod · 0.85
createFollowsTableMethod · 0.85

Calls 2

releaseMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected