| 578 | } |
| 579 | |
| 580 | Status DecompressBuffers(Compression::type compression, const IpcReadOptions& options, |
| 581 | ArrayDataVector* fields) { |
| 582 | struct BufferAccumulator { |
| 583 | using BufferPtrVector = std::vector<std::shared_ptr<Buffer>*>; |
| 584 | |
| 585 | void AppendFrom(const ArrayDataVector& fields) { |
| 586 | for (const auto& field : fields) { |
| 587 | for (auto& buffer : field->buffers) { |
| 588 | buffers_.push_back(&buffer); |
| 589 | } |
| 590 | AppendFrom(field->child_data); |
| 591 | } |
| 592 | // Dictionary buffers are decompressed separately (see ReadDictionary). |
| 593 | } |
| 594 | |
| 595 | BufferPtrVector Get(const ArrayDataVector& fields) && { |
| 596 | AppendFrom(fields); |
| 597 | return std::move(buffers_); |
| 598 | } |
| 599 | |
| 600 | BufferPtrVector buffers_; |
| 601 | }; |
| 602 | |
| 603 | // Flatten all buffers |
| 604 | auto buffers = BufferAccumulator{}.Get(*fields); |
| 605 | |
| 606 | std::unique_ptr<util::Codec> codec; |
| 607 | ARROW_ASSIGN_OR_RAISE(codec, util::Codec::Create(compression)); |
| 608 | |
| 609 | return ::arrow::internal::OptionalParallelFor( |
| 610 | options.use_threads, static_cast<int>(buffers.size()), [&](int i) { |
| 611 | ARROW_ASSIGN_OR_RAISE(*buffers[i], |
| 612 | DecompressBuffer(*buffers[i], options, codec.get())); |
| 613 | return Status::OK(); |
| 614 | }); |
| 615 | } |
| 616 | |
| 617 | // Helper class to run post-ArrayLoader steps: |
| 618 | // buffer decompression, dictionary resolution, buffer re-alignment. |
no test coverage detected