| 335 | } |
| 336 | |
| 337 | class ConcatenateImpl { |
| 338 | public: |
| 339 | ConcatenateImpl(const ArrayDataVector& in, MemoryPool* pool) |
| 340 | : in_(in), pool_(pool), out_(std::make_shared<ArrayData>()) { |
| 341 | out_->type = in_[0]->type; |
| 342 | for (const auto& in_array : in_) { |
| 343 | out_->length = SafeSignedAdd(out_->length, in_array->length); |
| 344 | if (out_->null_count == kUnknownNullCount || |
| 345 | in_array->null_count == kUnknownNullCount) { |
| 346 | out_->null_count = kUnknownNullCount; |
| 347 | continue; |
| 348 | } |
| 349 | out_->null_count = |
| 350 | SafeSignedAdd(out_->null_count.load(), in_array->null_count.load()); |
| 351 | } |
| 352 | out_->buffers.resize(in_[0]->buffers.size()); |
| 353 | out_->child_data.resize(in_[0]->child_data.size()); |
| 354 | for (auto& data : out_->child_data) { |
| 355 | data = std::make_shared<ArrayData>(); |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | Status Concatenate(std::shared_ptr<ArrayData>* out, ErrorHints* out_hints) && { |
| 360 | if (out_->null_count != 0 && internal::may_have_validity_bitmap(out_->type->id())) { |
| 361 | RETURN_NOT_OK(ConcatenateBitmaps(Bitmaps(0), pool_, &out_->buffers[0])); |
| 362 | } |
| 363 | auto status = VisitTypeInline(*out_->type, this); |
| 364 | if (!status.ok()) { |
| 365 | if (out_hints) { |
| 366 | out_hints->suggested_cast = std::move(suggested_cast_); |
| 367 | } |
| 368 | return status; |
| 369 | } |
| 370 | *out = std::move(out_); |
| 371 | return Status::OK(); |
| 372 | } |
| 373 | |
| 374 | Status Visit(const NullType&) { return Status::OK(); } |
| 375 | |
| 376 | Status Visit(const BooleanType&) { |
| 377 | return ConcatenateBitmaps(Bitmaps(1), pool_, &out_->buffers[1]); |
| 378 | } |
| 379 | |
| 380 | Status Visit(const FixedWidthType& fixed) { |
| 381 | // Handles numbers, decimal32, decimal64, decimal128, decimal256, fixed_size_binary |
| 382 | ARROW_ASSIGN_OR_RAISE(auto buffers, Buffers(1, fixed)); |
| 383 | return ConcatenateBuffers(buffers, pool_).Value(&out_->buffers[1]); |
| 384 | } |
| 385 | |
| 386 | Status Visit(const BinaryType& input_type) { |
| 387 | std::vector<Range> value_ranges; |
| 388 | ARROW_ASSIGN_OR_RAISE(auto index_buffers, Buffers(1, sizeof(int32_t))); |
| 389 | ARROW_ASSIGN_OR_RAISE( |
| 390 | auto outcome, ConcatenateOffsets<int32_t>(index_buffers, pool_, &out_->buffers[1], |
| 391 | &value_ranges)); |
| 392 | switch (outcome) { |
| 393 | case OffsetBufferOpOutcome::kOk: |
| 394 | break; |
no outgoing calls
no test coverage detected