MCPcopy Create free account
hub / github.com/apache/fory / array_data_from

Function array_data_from

cpp/fory/row/row.cc:177–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175
176template <typename value_type>
177std::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
193std::shared_ptr<ArrayData> ArrayData::from(const std::vector<int32_t> &vec) {
194 return array_data_from(vec.data(), static_cast<int>(vec.size()), 4,

Callers 1

fromMethod · 0.85

Calls 5

allocate_bufferFunction · 0.85
zero_paddingMethod · 0.80
unsafe_putMethod · 0.80
copy_fromMethod · 0.80
point_toMethod · 0.80

Tested by

no test coverage detected