| 544 | std::vector<internal::ContentDefinedChunker> content_defined_chunkers_; |
| 545 | |
| 546 | void StartFile() { |
| 547 | auto file_encryption_properties = properties_->file_encryption_properties(); |
| 548 | if (file_encryption_properties == nullptr) { |
| 549 | // Unencrypted parquet files always start with PAR1 |
| 550 | PARQUET_THROW_NOT_OK(sink_->Write(kParquetMagic, 4)); |
| 551 | } else { |
| 552 | // Check that all columns in columnEncryptionProperties exist in the schema. |
| 553 | auto encrypted_columns = file_encryption_properties->encrypted_columns(); |
| 554 | // if columnEncryptionProperties is empty, every column in file schema will be |
| 555 | // encrypted with footer key. |
| 556 | if (encrypted_columns.size() != 0) { |
| 557 | std::vector<std::string> column_path_vec; |
| 558 | std::vector<std::string> column_root_vec; |
| 559 | // First, save all column paths and root column names in schema. |
| 560 | for (int i = 0; i < num_columns(); i++) { |
| 561 | column_path_vec.push_back(schema_.Column(i)->path()->ToDotString()); |
| 562 | column_root_vec.push_back(schema_.Column(i)->path()->ToDotVector().at(0)); |
| 563 | } |
| 564 | |
| 565 | for (const auto& elem : encrypted_columns) { |
| 566 | // Check if this column exists in schema. |
| 567 | auto it = std::find(column_path_vec.begin(), column_path_vec.end(), elem.first); |
| 568 | if (it == column_path_vec.end()) { |
| 569 | // this column does not exist in the schema, this might be a root column name |
| 570 | // like `a` while there are `a.key_value.key` and `a.key_value.value` in the |
| 571 | // schema. |
| 572 | it = std::find(column_root_vec.begin(), column_root_vec.end(), elem.first); |
| 573 | if (it == column_root_vec.end()) { |
| 574 | // no encrypted columns exist with this root column name |
| 575 | std::stringstream ss; |
| 576 | ss << "Encrypted column " + elem.first + " not in file schema: "; |
| 577 | for (auto& cp : column_path_vec) { |
| 578 | ss << cp << " "; |
| 579 | } |
| 580 | throw ParquetException(ss.str()); |
| 581 | } |
| 582 | } |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | file_encryptor_ = std::make_unique<InternalFileEncryptor>( |
| 587 | file_encryption_properties, properties_->memory_pool()); |
| 588 | if (file_encryption_properties->encrypted_footer()) { |
| 589 | PARQUET_THROW_NOT_OK(sink_->Write(kParquetEMagic, 4)); |
| 590 | } else { |
| 591 | // Encrypted file with plaintext footer mode. |
| 592 | PARQUET_THROW_NOT_OK(sink_->Write(kParquetMagic, 4)); |
| 593 | } |
| 594 | } |
| 595 | if (properties_->bloom_filter_enabled()) { |
| 596 | bloom_filter_builder_ = BloomFilterBuilder::Make(schema(), properties_.get()); |
| 597 | } |
| 598 | if (properties_->page_index_enabled()) { |
| 599 | page_index_builder_ = PageIndexBuilder::Make(&schema_, file_encryptor_.get()); |
| 600 | } |
| 601 | } |
| 602 | }; |
| 603 |
nothing calls this directly
no test coverage detected