| 1242 | } |
| 1243 | |
| 1244 | std::shared_ptr<ArrayData> UnalignBuffers(const ArrayData& array) { |
| 1245 | std::vector<std::shared_ptr<Buffer>> new_buffers; |
| 1246 | new_buffers.reserve(array.buffers.size()); |
| 1247 | |
| 1248 | for (const auto& buffer : array.buffers) { |
| 1249 | if (!buffer) { |
| 1250 | new_buffers.emplace_back(); |
| 1251 | continue; |
| 1252 | } |
| 1253 | EXPECT_OK_AND_ASSIGN(std::shared_ptr<Buffer> padded, |
| 1254 | AllocateBuffer(buffer->size() + 1, default_memory_pool())); |
| 1255 | memcpy(padded->mutable_data() + 1, buffer->data(), buffer->size()); |
| 1256 | std::shared_ptr<Buffer> unaligned = SliceBuffer(padded, 1); |
| 1257 | new_buffers.push_back(std::move(unaligned)); |
| 1258 | } |
| 1259 | |
| 1260 | std::shared_ptr<ArrayData> array_data = std::make_shared<ArrayData>(array); |
| 1261 | array_data->buffers = std::move(new_buffers); |
| 1262 | return array_data; |
| 1263 | } |
| 1264 | |
| 1265 | std::shared_ptr<Array> UnalignBuffers(const Array& array) { |
| 1266 | std::shared_ptr<ArrayData> array_data = UnalignBuffers(*array.data()); |
no test coverage detected