From 188cacec542b08b57339730b8ae879064c2e079a Mon Sep 17 00:00:00 2001 From: Marco Neumann Date: Wed, 9 Jun 2021 10:10:58 +0200 Subject: [PATCH] refactor: use `Arc` to pass `ParquetFileMetaData` This will be handy when the catalog state must be able to return metadata objects so that we can create checkpoints, esp. when we use multi-chunk parquet files in some midterm future. --- parquet_file/src/catalog.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/parquet_file/src/catalog.rs b/parquet_file/src/catalog.rs index 1ee5525e92..3c2916b86c 100644 --- a/parquet_file/src/catalog.rs +++ b/parquet_file/src/catalog.rs @@ -203,7 +203,7 @@ pub struct CatalogParquetInfo { pub path: DirsAndFileName, /// Associated parquet metadata. - pub metadata: ParquetMetaData, + pub metadata: Arc, } /// Abstraction over how the in-memory state of the catalog works. @@ -815,8 +815,11 @@ where } proto::transaction::action::Action::AddParquet(a) => { let path = parse_dirs_and_filename(&a.path)?; + let metadata = thrift_to_parquet_metadata(&a.metadata).context(MetadataDecodingFailed)?; + let metadata = Arc::new(metadata); + state.add( Arc::clone(object_store), server_id, @@ -1116,7 +1119,7 @@ pub mod test_helpers { #[derive(Clone, Debug)] pub struct TestCatalogStateInner { /// Map of all parquet files that are currently registered. - pub parquet_files: HashMap, + pub parquet_files: HashMap>, } /// In-memory catalog state, for testing. @@ -2005,7 +2008,7 @@ mod tests { let mut files: Vec<(String, ParquetMetaData)> = guard .parquet_files .iter() - .map(|(path, md)| (path.display(), md.clone())) + .map(|(path, md)| (path.display(), md.as_ref().clone())) .collect(); files.sort_by_key(|(path, _)| path.clone()); files