Skip to main content

nautilus_persistence/backend/parquet/
mod.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Parquet catalog backend.
17
18use std::sync::Arc;
19
20use crate::catalog::{factory as catalog_factory, traits as catalog_traits};
21
22pub mod catalog;
23pub mod consolidation;
24pub mod delete;
25pub mod feather_session;
26pub mod file_admin;
27pub mod intervals;
28pub mod io;
29pub mod migration;
30pub mod paths;
31pub mod writer;
32
33pub(crate) mod metadata;
34
35/// Default number of rows in a Parquet row group.
36pub const DEFAULT_ROW_GROUP_SIZE: usize = 131_072;
37
38pub(crate) fn register_catalog_factory(registry: &mut catalog_factory::CatalogFactoryRegistry) {
39    registry.insert(
40        catalog_factory::PARQUET_CATALOG_FACTORY_NAME.to_string(),
41        Arc::new(|config: &catalog_factory::CatalogConnectConfig| {
42            let params = config.params.as_ref();
43            Ok(Box::new(catalog::ParquetDataCatalog::from_uri(
44                &config.uri,
45                config.storage_options.clone(),
46                params.and_then(|params| params.get_usize("batch_size")),
47                params
48                    .and_then(|params| params.get_u64("compression"))
49                    .map(compression_from_code),
50                params.and_then(|params| params.get_usize("max_row_group_size")),
51            )?) as catalog_traits::DataCatalog)
52        }),
53    );
54}
55
56fn compression_from_code(code: u64) -> ::parquet::basic::Compression {
57    match code {
58        0 => ::parquet::basic::Compression::UNCOMPRESSED,
59        2 => ::parquet::basic::Compression::GZIP(::parquet::basic::GzipLevel::default()),
60        3 => ::parquet::basic::Compression::LZO,
61        4 => ::parquet::basic::Compression::BROTLI(::parquet::basic::BrotliLevel::default()),
62        5 => ::parquet::basic::Compression::LZ4,
63        6 => ::parquet::basic::Compression::ZSTD(::parquet::basic::ZstdLevel::default()),
64        _ => ::parquet::basic::Compression::SNAPPY,
65    }
66}