Helper to create a struct schema with multiple fields
| 78 | |
| 79 | // Helper to create a struct schema with multiple fields |
| 80 | inline void createStructSchema(ArrowSchema* schema, int n_fields) { |
| 81 | schema->format = "+s"; // struct |
| 82 | schema->name = nullptr; |
| 83 | schema->metadata = nullptr; |
| 84 | schema->flags = 0; |
| 85 | schema->n_children = n_fields; |
| 86 | schema->children = static_cast<ArrowSchema**>(malloc(sizeof(ArrowSchema*) * n_fields)); |
| 87 | for (int i = 0; i < n_fields; i++) { |
| 88 | schema->children[i] = static_cast<ArrowSchema*>(malloc(sizeof(ArrowSchema))); |
| 89 | } |
| 90 | schema->dictionary = nullptr; |
| 91 | schema->release = [](ArrowSchema* s) { |
| 92 | if (s->children) { |
| 93 | for (int64_t i = 0; i < s->n_children; i++) { |
| 94 | if (s->children[i]->release) { |
| 95 | s->children[i]->release(s->children[i]); |
| 96 | } |
| 97 | free(s->children[i]); |
| 98 | } |
| 99 | free(s->children); |
| 100 | } |
| 101 | s->release = nullptr; |
| 102 | }; |
| 103 | schema->private_data = nullptr; |
| 104 | } |
| 105 | |
| 106 | // Helper to create an int32 array from vector |
| 107 | inline void createInt32Array(ArrowArray* array, const std::vector<int32_t>& data) { |
no test coverage detected