| 233 | // \param[in,out] sizes The concatenated sizes buffer |
| 234 | template <typename offset_type> |
| 235 | Result<OffsetBufferOpOutcome> ConcatenateListViewOffsets( |
| 236 | const ArrayDataVector& in, offset_type* sizes, const BufferVector& offset_buffers, |
| 237 | const std::vector<Range>& value_ranges, MemoryPool* pool, |
| 238 | std::shared_ptr<Buffer>* out) { |
| 239 | DCHECK_EQ(offset_buffers.size(), value_ranges.size()); |
| 240 | |
| 241 | // Allocate resulting offsets buffer and initialize it with zeros |
| 242 | const int64_t out_size_in_bytes = SumBufferSizesInBytes(offset_buffers); |
| 243 | ARROW_ASSIGN_OR_RAISE(*out, AllocateBuffer(out_size_in_bytes, pool)); |
| 244 | memset((*out)->mutable_data(), 0, static_cast<size_t>((*out)->size())); |
| 245 | |
| 246 | auto* out_offsets = (*out)->mutable_data_as<offset_type>(); |
| 247 | |
| 248 | int64_t num_child_values = 0; |
| 249 | int64_t elements_length = 0; |
| 250 | for (size_t i = 0; i < offset_buffers.size(); ++i) { |
| 251 | const auto displacement = |
| 252 | static_cast<offset_type>(num_child_values - value_ranges[i].offset); |
| 253 | ARROW_ASSIGN_OR_RAISE(auto outcome, |
| 254 | PutListViewOffsets(*in[i], /*sizes=*/sizes + elements_length, |
| 255 | /*src=*/*offset_buffers[i], displacement, |
| 256 | /*dst=*/out_offsets + elements_length)); |
| 257 | if (ARROW_PREDICT_FALSE(outcome != OffsetBufferOpOutcome::kOk)) { |
| 258 | return outcome; |
| 259 | } |
| 260 | elements_length += offset_buffers[i]->size() / sizeof(offset_type); |
| 261 | num_child_values += value_ranges[i].length; |
| 262 | if (num_child_values > std::numeric_limits<offset_type>::max()) { |
| 263 | return OffsetBufferOpOutcome::kOffsetOverflow; |
| 264 | } |
| 265 | } |
| 266 | DCHECK_EQ(elements_length, |
| 267 | static_cast<int64_t>(out_size_in_bytes / sizeof(offset_type))); |
| 268 | |
| 269 | return OffsetBufferOpOutcome::kOk; |
| 270 | } |
| 271 | |
| 272 | template <typename offset_type> |
| 273 | Result<OffsetBufferOpOutcome> PutListViewOffsets(const ArrayData& input, |
nothing calls this directly
no test coverage detected