| 1295 | } |
| 1296 | |
| 1297 | std::shared_ptr<ArrayData> UnalignBuffers(const ArrayData& array) { |
| 1298 | std::vector<std::shared_ptr<Buffer>> new_buffers; |
| 1299 | new_buffers.reserve(array.buffers.size()); |
| 1300 | |
| 1301 | for (const auto& buffer : array.buffers) { |
| 1302 | if (!buffer) { |
| 1303 | new_buffers.emplace_back(); |
| 1304 | continue; |
| 1305 | } |
| 1306 | EXPECT_OK_AND_ASSIGN(std::shared_ptr<Buffer> padded, |
| 1307 | AllocateBuffer(buffer->size() + 1, default_memory_pool())); |
| 1308 | memcpy(padded->mutable_data() + 1, buffer->data(), buffer->size()); |
| 1309 | std::shared_ptr<Buffer> unaligned = SliceBuffer(padded, 1); |
| 1310 | new_buffers.push_back(std::move(unaligned)); |
| 1311 | } |
| 1312 | |
| 1313 | std::shared_ptr<ArrayData> array_data = std::make_shared<ArrayData>(array); |
| 1314 | array_data->buffers = std::move(new_buffers); |
| 1315 | return array_data; |
| 1316 | } |
| 1317 | |
| 1318 | std::shared_ptr<Array> UnalignBuffers(const Array& array) { |
| 1319 | std::shared_ptr<ArrayData> array_data = UnalignBuffers(*array.data()); |
no test coverage detected