| 1500 | } |
| 1501 | |
| 1502 | Status Close() override { |
| 1503 | // Write 0 EOS message for compatibility with sequential readers |
| 1504 | RETURN_NOT_OK(WriteEOS()); |
| 1505 | |
| 1506 | // Write file footer |
| 1507 | RETURN_NOT_OK(UpdatePosition()); |
| 1508 | int64_t initial_position = position_; |
| 1509 | RETURN_NOT_OK( |
| 1510 | WriteFileFooter(*schema_, dictionaries_, record_batches_, metadata_, sink_)); |
| 1511 | |
| 1512 | // Write footer length |
| 1513 | RETURN_NOT_OK(UpdatePosition()); |
| 1514 | int32_t footer_length = static_cast<int32_t>(position_ - initial_position); |
| 1515 | if (footer_length <= 0) { |
| 1516 | return Status::Invalid("Invalid file footer"); |
| 1517 | } |
| 1518 | |
| 1519 | // write footer length in little endian |
| 1520 | footer_length = bit_util::ToLittleEndian(footer_length); |
| 1521 | RETURN_NOT_OK(Write(&footer_length, sizeof(int32_t))); |
| 1522 | |
| 1523 | // Write magic bytes to end file |
| 1524 | return Write(kArrowMagicBytes.data(), kArrowMagicBytes.size()); |
| 1525 | } |
| 1526 | |
| 1527 | protected: |
| 1528 | std::shared_ptr<Schema> schema_; |
no test coverage detected