| 593 | } |
| 594 | |
| 595 | Status DecompressBuffers(Compression::type compression, const IpcReadOptions& options, |
| 596 | ArrayDataVector* fields) { |
| 597 | struct BufferAccumulator { |
| 598 | using BufferPtrVector = std::vector<std::shared_ptr<Buffer>*>; |
| 599 | |
| 600 | void AppendFrom(const ArrayDataVector& fields) { |
| 601 | for (const auto& field : fields) { |
| 602 | for (auto& buffer : field->buffers) { |
| 603 | buffers_.push_back(&buffer); |
| 604 | } |
| 605 | AppendFrom(field->child_data); |
| 606 | } |
| 607 | // Dictionary buffers are decompressed separately (see ReadDictionary). |
| 608 | } |
| 609 | |
| 610 | BufferPtrVector Get(const ArrayDataVector& fields) && { |
| 611 | AppendFrom(fields); |
| 612 | return std::move(buffers_); |
| 613 | } |
| 614 | |
| 615 | BufferPtrVector buffers_; |
| 616 | }; |
| 617 | |
| 618 | // Flatten all buffers |
| 619 | auto buffers = BufferAccumulator{}.Get(*fields); |
| 620 | |
| 621 | std::unique_ptr<util::Codec> codec; |
| 622 | ARROW_ASSIGN_OR_RAISE(codec, util::Codec::Create(compression)); |
| 623 | |
| 624 | return ::arrow::internal::OptionalParallelFor( |
| 625 | options.use_threads, static_cast<int>(buffers.size()), [&](int i) { |
| 626 | ARROW_ASSIGN_OR_RAISE(*buffers[i], |
| 627 | DecompressBuffer(*buffers[i], options, codec.get())); |
| 628 | return Status::OK(); |
| 629 | }); |
| 630 | } |
| 631 | |
| 632 | // Helper class to run post-ArrayLoader steps: |
| 633 | // buffer decompression, dictionary resolution, buffer re-alignment. |
no test coverage detected