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