|
95 | 95 | //! ```
|
96 | 96 | //!
|
97 | 97 | //! #![cfg(feature = "encryption")]
|
98 |
| -//! # Example of reading uniformly encrypted parquet file into arrow record batch |
99 |
| -//! |
100 |
| -#![cfg(feature = "encryption")] |
101 |
| -//! ```rust |
102 |
| -#![cfg(not(feature = "encryption"))] |
103 |
| -//! ```ignore |
104 |
| -//! # use arrow_array::{Int32Array, ArrayRef}; |
105 |
| -//! # use arrow_array::{types, RecordBatch}; |
106 |
| -//! # use parquet::arrow::arrow_reader::{ |
107 |
| -//! # ArrowReaderMetadata, ArrowReaderOptions, ParquetRecordBatchReaderBuilder, |
108 |
| -//! # }; |
109 |
| -//! # use arrow_array::cast::AsArray; |
110 |
| -//! # use parquet::file::metadata::ParquetMetaData; |
111 |
| -//! # use tempfile::tempfile; |
112 |
| -//! # use std::fs::File; |
113 |
| -//! # use parquet::encryption::decrypt::FileDecryptionProperties; |
114 |
| -//! # let test_data = arrow::util::test_util::parquet_test_data(); |
115 |
| -//! # let path = format!("{test_data}/uniform_encryption.parquet.encrypted"); |
116 |
| -//! # |
117 |
| -//! let file = File::open(path).unwrap(); |
118 |
| -//! |
119 |
| -//! let key_code: &[u8] = "0123456789012345".as_bytes(); |
120 |
| -//! let decryption_properties = FileDecryptionProperties::builder(key_code.to_vec()) |
121 |
| -//! .build() |
122 |
| -//! .unwrap(); |
123 |
| -//! |
124 |
| -//! let options = |
125 |
| -//! ArrowReaderOptions::default().with_file_decryption_properties(decryption_properties); |
126 |
| -//! let reader_metadata = ArrowReaderMetadata::load(&file, options.clone()).unwrap(); |
127 |
| -//! let metadata = reader_metadata.metadata(); |
128 |
| -//! let file_metadata = metadata.file_metadata(); |
129 |
| -//! |
130 |
| -//! println!("Read {} rows.", file_metadata.num_rows()); |
131 |
| -//! |
132 |
| -//! let builder = ParquetRecordBatchReaderBuilder::try_new_with_options(file, options).unwrap(); |
133 |
| -//! println!("Converted arrow schema is: {}", builder.schema()); |
134 |
| -//! |
135 |
| -//! let mut reader = builder.build().unwrap(); |
136 |
| -//! |
137 |
| -//! let record_batch = reader.next().unwrap().unwrap(); |
138 |
| -//! |
139 |
| -//! println!("Read {} records.", record_batch.num_rows()); |
140 |
| -//! ``` |
141 |
| -//! |
142 |
| -//! #![cfg(feature = "encryption")] |
143 | 98 | //! # Example of reading non-uniformly encrypted parquet file into arrow record batch
|
144 | 99 | //!
|
145 | 100 | #![cfg(feature = "encryption")]
|
|
161 | 116 | //! #
|
162 | 117 | //! let file = File::open(path).unwrap();
|
163 | 118 | //!
|
164 |
| -//! // There is always a footer key even with a plaintext footer, |
165 |
| -//! // but this is used for signing the footer. |
| 119 | +//! // Define the AES encryption keys required required for decrypting the footer metadata |
| 120 | +//! // and column-specific data. If only a footer key is used then it is assumed that the |
| 121 | +//! // file uses uniform encryption and all columns are encrypted with the footer key. |
| 122 | +//! // If any column keys are specified, other columns without a key provided are assumed |
| 123 | +//! // to be unencrypted |
166 | 124 | //! let footer_key = "0123456789012345".as_bytes(); // Keys are 128 bits (16 bytes)
|
167 | 125 | //! let column_1_key = "1234567890123450".as_bytes();
|
168 | 126 | //! let column_2_key = "1234567890123451".as_bytes();
|
|
0 commit comments