| 766 | } // namespace |
| 767 | |
| 768 | Status WriteIpcPayload(const IpcPayload& payload, const IpcWriteOptions& options, |
| 769 | io::OutputStream* dst, int32_t* metadata_length) { |
| 770 | RETURN_NOT_OK(WriteMessage(*payload.metadata, options, dst, metadata_length)); |
| 771 | |
| 772 | #ifndef NDEBUG |
| 773 | RETURN_NOT_OK(CheckAligned(dst)); |
| 774 | #endif |
| 775 | |
| 776 | // Now write the buffers |
| 777 | for (size_t i = 0; i < payload.body_buffers.size(); ++i) { |
| 778 | const std::shared_ptr<Buffer>& buffer = payload.body_buffers[i]; |
| 779 | int64_t size = 0; |
| 780 | int64_t padding = 0; |
| 781 | |
| 782 | // The buffer might be null if we are handling zero row lengths. |
| 783 | if (buffer) { |
| 784 | size = buffer->size(); |
| 785 | padding = bit_util::RoundUpToMultipleOf8(size) - size; |
| 786 | } |
| 787 | |
| 788 | if (size > 0) { |
| 789 | RETURN_NOT_OK(dst->Write(buffer)); |
| 790 | } |
| 791 | |
| 792 | if (padding > 0) { |
| 793 | RETURN_NOT_OK(dst->Write(kPaddingBytes, padding)); |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | #ifndef NDEBUG |
| 798 | RETURN_NOT_OK(CheckAligned(dst)); |
| 799 | #endif |
| 800 | |
| 801 | return Status::OK(); |
| 802 | } |
| 803 | |
| 804 | Status GetSchemaPayload(const Schema& schema, const IpcWriteOptions& options, |
| 805 | const DictionaryFieldMapper& mapper, IpcPayload* out) { |