| 865 | const ApplicationVersion& writer_version() const { return writer_version_; } |
| 866 | |
| 867 | void WriteTo(::arrow::io::OutputStream* dst, |
| 868 | const std::shared_ptr<Encryptor>& encryptor) const { |
| 869 | ThriftSerializer serializer; |
| 870 | // Only in encrypted files with plaintext footers the |
| 871 | // encryption_algorithm is set in footer |
| 872 | if (is_encryption_algorithm_set()) { |
| 873 | const auto serialized_data_span = serializer.SerializeToBuffer(metadata_.get()); |
| 874 | const auto serialized_data_len = static_cast<int64_t>(serialized_data_span.size()); |
| 875 | |
| 876 | // encrypt the footer key |
| 877 | std::vector<uint8_t> encrypted_data( |
| 878 | encryptor->CiphertextLength(serialized_data_len)); |
| 879 | int32_t encrypted_len = encryptor->Encrypt(serialized_data_span, encrypted_data); |
| 880 | |
| 881 | // write unencrypted footer |
| 882 | PARQUET_THROW_NOT_OK(dst->Write(serialized_data_span.data(), serialized_data_len)); |
| 883 | // Write signature (nonce and tag) |
| 884 | PARQUET_THROW_NOT_OK( |
| 885 | dst->Write(encrypted_data.data() + 4, encryption::kNonceLength)); |
| 886 | PARQUET_THROW_NOT_OK( |
| 887 | dst->Write(encrypted_data.data() + encrypted_len - encryption::kGcmTagLength, |
| 888 | encryption::kGcmTagLength)); |
| 889 | } else { // either plaintext file (when encryptor is null) |
| 890 | // or encrypted file with encrypted footer |
| 891 | serializer.Serialize(metadata_.get(), dst, encryptor.get()); |
| 892 | } |
| 893 | } |
| 894 | |
| 895 | std::unique_ptr<RowGroupMetaData> RowGroup(int i) { |
| 896 | if (!(i >= 0 && i < num_row_groups())) { |
nothing calls this directly
no test coverage detected