| 122 | } |
| 123 | |
| 124 | arrow::Status ReadEncryptedFile(const std::string& path_to_file) { |
| 125 | // Get a configured crypto factory and kms connection conf |
| 126 | auto crypto_factory = GetCryptoFactory(); |
| 127 | auto kms_connection_config = |
| 128 | std::make_shared<parquet::encryption::KmsConnectionConfig>(); |
| 129 | |
| 130 | // Create decryption properties. |
| 131 | auto decryption_config = |
| 132 | std::make_shared<parquet::encryption::DecryptionConfiguration>(); |
| 133 | auto parquet_decryption_config = std::make_shared<ds::ParquetDecryptionConfig>(); |
| 134 | parquet_decryption_config->crypto_factory = crypto_factory; |
| 135 | parquet_decryption_config->kms_connection_config = kms_connection_config; |
| 136 | parquet_decryption_config->decryption_config = std::move(decryption_config); |
| 137 | |
| 138 | // Set scan options. |
| 139 | auto parquet_scan_options = std::make_shared<ds::ParquetFragmentScanOptions>(); |
| 140 | parquet_scan_options->parquet_decryption_config = std::move(parquet_decryption_config); |
| 141 | |
| 142 | // Get configured Parquet file format |
| 143 | auto file_format = std::make_shared<ds::ParquetFileFormat>(); |
| 144 | file_format->default_fragment_scan_options = std::move(parquet_scan_options); |
| 145 | |
| 146 | // Get the FileSystem. |
| 147 | auto file_system = std::make_shared<fs::LocalFileSystem>(); |
| 148 | |
| 149 | // Get FileInfo objects for all files under the base directory |
| 150 | fs::FileSelector selector; |
| 151 | selector.base_dir = path_to_file; |
| 152 | selector.recursive = true; |
| 153 | |
| 154 | // Create the dataset |
| 155 | ds::FileSystemFactoryOptions factory_options; |
| 156 | ARROW_ASSIGN_OR_RAISE(auto dataset_factory, |
| 157 | ds::FileSystemDatasetFactory::Make(file_system, selector, |
| 158 | file_format, factory_options)); |
| 159 | ARROW_ASSIGN_OR_RAISE(auto dataset, dataset_factory->Finish()); |
| 160 | ARROW_ASSIGN_OR_RAISE(auto scanner_builder, dataset->NewScan()); |
| 161 | ARROW_ASSIGN_OR_RAISE(auto scanner, scanner_builder->Finish()); |
| 162 | ARROW_ASSIGN_OR_RAISE(auto table, scanner->ToTable()); |
| 163 | std::cout << "Table size: " << table->num_rows() << "\n"; |
| 164 | return arrow::Status::OK(); |
| 165 | } |
| 166 | |
| 167 | arrow::Status RunExamples(const std::string& path_to_file) { |
| 168 | ARROW_RETURN_NOT_OK(WriteEncryptedFile(path_to_file)); |
no test coverage detected