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