| 175 | |
| 176 | template <typename value_type> |
| 177 | std::shared_ptr<ArrayData> array_data_from(const value_type *data, |
| 178 | int num_elements, int element_size, |
| 179 | const ListTypePtr &type) { |
| 180 | auto array_data = std::make_shared<ArrayData>(type); |
| 181 | std::shared_ptr<Buffer> buffer; |
| 182 | auto header_bytes = ArrayData::calculate_header_in_bytes(num_elements); |
| 183 | auto size_bytes = header_bytes + num_elements * element_size; |
| 184 | allocate_buffer(static_cast<int32_t>(size_bytes), &buffer); |
| 185 | buffer->zero_padding(); |
| 186 | buffer->unsafe_put(0, static_cast<int64_t>(num_elements)); |
| 187 | buffer->copy_from(header_bytes, reinterpret_cast<const uint8_t *>(data), 0, |
| 188 | static_cast<int32_t>(num_elements * element_size)); |
| 189 | array_data->point_to(buffer, 0, size_bytes); |
| 190 | return array_data; |
| 191 | } |
| 192 | |
| 193 | std::shared_ptr<ArrayData> ArrayData::from(const std::vector<int32_t> &vec) { |
| 194 | return array_data_from(vec.data(), static_cast<int>(vec.size()), 4, |
no test coverage detected