| 1523 | } |
| 1524 | |
| 1525 | Status Close() override { |
| 1526 | // Write 0 EOS message for compatibility with sequential readers |
| 1527 | RETURN_NOT_OK(WriteEOS()); |
| 1528 | |
| 1529 | // Write file footer |
| 1530 | RETURN_NOT_OK(UpdatePosition()); |
| 1531 | int64_t initial_position = position_; |
| 1532 | RETURN_NOT_OK( |
| 1533 | WriteFileFooter(*schema_, dictionaries_, record_batches_, metadata_, sink_)); |
| 1534 | |
| 1535 | // Write footer length |
| 1536 | RETURN_NOT_OK(UpdatePosition()); |
| 1537 | int32_t footer_length = static_cast<int32_t>(position_ - initial_position); |
| 1538 | if (footer_length <= 0) { |
| 1539 | return Status::Invalid("Invalid file footer"); |
| 1540 | } |
| 1541 | |
| 1542 | // write footer length in little endian |
| 1543 | footer_length = bit_util::ToLittleEndian(footer_length); |
| 1544 | RETURN_NOT_OK(Write(&footer_length, sizeof(int32_t))); |
| 1545 | |
| 1546 | // Write magic bytes to end file |
| 1547 | return Write(kArrowMagicBytes.data(), kArrowMagicBytes.size()); |
| 1548 | } |
| 1549 | |
| 1550 | protected: |
| 1551 | std::shared_ptr<Schema> schema_; |
no test coverage detected