Skip to content

Commit

Permalink
Work
Browse files Browse the repository at this point in the history
  • Loading branch information
rok committed Feb 14, 2025
1 parent 877ca0c commit 7e5c636
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions parquet/src/column/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> {
data_page_boundary_ascending: true,
data_page_boundary_descending: true,
last_non_null_data_page_min_max: None,
// metadata_encryptor: metadata_encryptor,
// data_encryptor: data_encryptor,
}
}

Expand Down
19 changes: 17 additions & 2 deletions parquet/src/file/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ pub struct SerializedFileWriter<W: Write> {
// kv_metadatas will be appended to `props` when `write_metadata`
kv_metadatas: Vec<KeyValue>,
finished: bool,
file_encryptor: FileEncryptor,
}

impl<W: Write> Debug for SerializedFileWriter<W> {
Expand All @@ -173,19 +174,28 @@ impl<W: Write + Send> SerializedFileWriter<W> {
/// Creates new file writer.
pub fn new(buf: W, schema: TypePtr, properties: WriterPropertiesPtr) -> Result<Self> {
let mut buf = TrackedWrite::new(buf);
Self::start_file(&mut buf)?;
if properties.file_encryption_properties().is_some() {
// todo: check if all columns in properties.file_encryption_properties().column_keys
// are present in the schema
let fep = properties.file_encryption_properties().unwrap();
Self::start_encrypted_file(&mut buf)?;
} else {
Self::start_file(&mut buf)?;
}
Ok(Self {
buf,
schema: schema.clone(),
descr: Arc::new(SchemaDescriptor::new(schema)),
props: properties,
props: properties.clone(),
row_groups: vec![],
bloom_filters: vec![],
column_indexes: Vec::new(),
offset_indexes: Vec::new(),
row_group_index: 0,
kv_metadatas: Vec::new(),
finished: false,
#[cfg(feature = "encryption")]
file_encryptor: FileEncryptor::new(properties.file_encryption_properties().unwrap().clone(), vec![], vec![])
})
}

Expand Down Expand Up @@ -274,6 +284,11 @@ impl<W: Write + Send> SerializedFileWriter<W> {
Ok(())
}

fn start_encrypted_file(buf: &mut TrackedWrite<W>) -> Result<()> {
buf.write_all(&PARQUET_MAGIC)?;
Ok(())
}

/// Assembles and writes metadata at the end of the file.
fn write_metadata(&mut self) -> Result<parquet::FileMetaData> {
self.finished = true;
Expand Down

0 comments on commit 7e5c636

Please sign in to comment.