-
Notifications
You must be signed in to change notification settings - Fork 861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve parquet WriterProperites
and ReaderProperties
docs
#4392
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,55 +15,7 @@ | |
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
//! [`WriterProperties`] | ||
//! | ||
//! # Usage | ||
//! | ||
//! ```rust | ||
//! use parquet::{ | ||
//! basic::{Compression, Encoding}, | ||
//! file::properties::*, | ||
//! schema::types::ColumnPath, | ||
//! }; | ||
//! | ||
//! // Create properties with default configuration. | ||
//! let props = WriterProperties::default(); | ||
//! | ||
//! // Use properties builder to set certain options and assemble the configuration. | ||
//! let props = WriterProperties::builder() | ||
//! .set_writer_version(WriterVersion::PARQUET_1_0) | ||
//! .set_encoding(Encoding::PLAIN) | ||
//! .set_column_encoding(ColumnPath::from("col1"), Encoding::DELTA_BINARY_PACKED) | ||
//! .set_compression(Compression::SNAPPY) | ||
//! .build(); | ||
//! | ||
//! assert_eq!(props.writer_version(), WriterVersion::PARQUET_1_0); | ||
//! assert_eq!( | ||
//! props.encoding(&ColumnPath::from("col1")), | ||
//! Some(Encoding::DELTA_BINARY_PACKED) | ||
//! ); | ||
//! assert_eq!( | ||
//! props.encoding(&ColumnPath::from("col2")), | ||
//! Some(Encoding::PLAIN) | ||
//! ); | ||
//! ``` | ||
//! | ||
//! Reader properties. | ||
//! | ||
//! # Usage | ||
//! | ||
//! ```rust | ||
//! use parquet::file::properties::ReaderProperties; | ||
//! | ||
//! // Create properties with default configuration. | ||
//! let props = ReaderProperties::builder().build(); | ||
//! | ||
//! // Use properties builder to set certain options and assemble the configuration. | ||
//! let props = ReaderProperties::builder() | ||
//! .set_backward_compatible_lz4(false) | ||
//! .build(); | ||
//! ``` | ||
|
||
//! Configuration via [`WriterProperties`] and [`ReaderProperties`] | ||
use std::{collections::HashMap, sync::Arc}; | ||
|
||
use crate::basic::{Compression, Encoding}; | ||
|
@@ -72,20 +24,30 @@ use crate::file::metadata::KeyValue; | |
use crate::format::SortingColumn; | ||
use crate::schema::types::ColumnPath; | ||
|
||
const DEFAULT_PAGE_SIZE: usize = 1024 * 1024; | ||
const DEFAULT_WRITE_BATCH_SIZE: usize = 1024; | ||
const DEFAULT_WRITER_VERSION: WriterVersion = WriterVersion::PARQUET_1_0; | ||
const DEFAULT_COMPRESSION: Compression = Compression::UNCOMPRESSED; | ||
const DEFAULT_DICTIONARY_ENABLED: bool = true; | ||
const DEFAULT_DICTIONARY_PAGE_SIZE_LIMIT: usize = DEFAULT_PAGE_SIZE; | ||
const DEFAULT_STATISTICS_ENABLED: EnabledStatistics = EnabledStatistics::Page; | ||
const DEFAULT_MAX_STATISTICS_SIZE: usize = 4096; | ||
const DEFAULT_MAX_ROW_GROUP_SIZE: usize = 1024 * 1024; | ||
const DEFAULT_CREATED_BY: &str = | ||
/// Default value for [`WriterProperties::data_page_size_limit`] | ||
pub const DEFAULT_PAGE_SIZE: usize = 1024 * 1024; | ||
/// Default value for [`WriterProperties::write_batch_size`] | ||
pub const DEFAULT_WRITE_BATCH_SIZE: usize = 1024; | ||
/// Default value for [`WriterProperties::writer_version`] | ||
pub const DEFAULT_WRITER_VERSION: WriterVersion = WriterVersion::PARQUET_1_0; | ||
/// Default value for [`WriterProperties::compression`] | ||
pub const DEFAULT_COMPRESSION: Compression = Compression::UNCOMPRESSED; | ||
/// Default value for [`WriterProperties::dictionary_enabled`] | ||
pub const DEFAULT_DICTIONARY_ENABLED: bool = true; | ||
/// Default value for [`WriterProperties::dictionary_page_size_limit`] | ||
pub const DEFAULT_DICTIONARY_PAGE_SIZE_LIMIT: usize = DEFAULT_PAGE_SIZE; | ||
/// Default value for [`WriterProperties::statistics_enabled`] | ||
pub const DEFAULT_STATISTICS_ENABLED: EnabledStatistics = EnabledStatistics::Page; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what I was looking for, but since the value was not I could have included the value in the text of |
||
/// Default value for [`WriterProperties::max_statistics_size`] | ||
pub const DEFAULT_MAX_STATISTICS_SIZE: usize = 4096; | ||
/// Default value for [`WriterProperties::max_row_group_size`] | ||
pub const DEFAULT_MAX_ROW_GROUP_SIZE: usize = 1024 * 1024; | ||
/// Default value for [`WriterProperties::created_by`] | ||
pub const DEFAULT_CREATED_BY: &str = | ||
concat!("parquet-rs version ", env!("CARGO_PKG_VERSION")); | ||
/// default value for the false positive probability used in a bloom filter. | ||
/// Default value for [`BloomFilterProperties::fpp`] | ||
pub const DEFAULT_BLOOM_FILTER_FPP: f64 = 0.05; | ||
/// default value for the expected number of distinct values used in a bloom filter. | ||
/// Default value for [`BloomFilterProperties::ndv`] | ||
pub const DEFAULT_BLOOM_FILTER_NDV: u64 = 1_000_000_u64; | ||
|
||
/// Parquet writer version. | ||
|
@@ -111,10 +73,41 @@ impl WriterVersion { | |
/// Reference counted writer properties. | ||
pub type WriterPropertiesPtr = Arc<WriterProperties>; | ||
|
||
/// Writer properties. | ||
/// Configuration settings for writing parquet files. | ||
/// | ||
/// All properties except the key-value metadata are immutable, | ||
/// use [`WriterPropertiesBuilder`] to assemble these properties. | ||
/// | ||
/// # Example | ||
/// | ||
/// ```rust | ||
/// use parquet::{ | ||
/// basic::{Compression, Encoding}, | ||
/// file::properties::*, | ||
/// schema::types::ColumnPath, | ||
/// }; | ||
/// | ||
/// // Create properties with default configuration. | ||
/// let props = WriterProperties::default(); | ||
/// | ||
/// // Use properties builder to set certain options and assemble the configuration. | ||
/// let props = WriterProperties::builder() | ||
/// .set_writer_version(WriterVersion::PARQUET_1_0) | ||
/// .set_encoding(Encoding::PLAIN) | ||
/// .set_column_encoding(ColumnPath::from("col1"), Encoding::DELTA_BINARY_PACKED) | ||
/// .set_compression(Compression::SNAPPY) | ||
/// .build(); | ||
/// | ||
/// assert_eq!(props.writer_version(), WriterVersion::PARQUET_1_0); | ||
/// assert_eq!( | ||
/// props.encoding(&ColumnPath::from("col1")), | ||
/// Some(Encoding::DELTA_BINARY_PACKED) | ||
/// ); | ||
/// assert_eq!( | ||
/// props.encoding(&ColumnPath::from("col2")), | ||
/// Some(Encoding::PLAIN) | ||
/// ); | ||
/// ``` | ||
#[derive(Debug, Clone)] | ||
pub struct WriterProperties { | ||
data_page_size_limit: usize, | ||
|
@@ -307,7 +300,8 @@ impl WriterProperties { | |
} | ||
} | ||
|
||
/// Writer properties builder. | ||
/// Builder for parquet file writer configuration. See example on | ||
/// [`WriterProperties`] | ||
pub struct WriterPropertiesBuilder { | ||
data_page_size_limit: usize, | ||
dictionary_page_size_limit: usize, | ||
|
@@ -809,10 +803,24 @@ pub type ReaderPropertiesPtr = Arc<ReaderProperties>; | |
|
||
const DEFAULT_READ_BLOOM_FILTER: bool = false; | ||
|
||
/// Reader properties. | ||
/// Configuration settings for reading parquet files. | ||
/// | ||
/// All properties are immutable and `Send` + `Sync`. | ||
/// Use [`ReaderPropertiesBuilder`] to assemble these properties. | ||
/// | ||
/// # Example | ||
/// | ||
/// ```rust | ||
/// use parquet::file::properties::ReaderProperties; | ||
/// | ||
/// // Create properties with default configuration. | ||
/// let props = ReaderProperties::builder().build(); | ||
/// | ||
/// // Use properties builder to set certain options and assemble the configuration. | ||
/// let props = ReaderProperties::builder() | ||
/// .set_backward_compatible_lz4(false) | ||
/// .build(); | ||
/// ``` | ||
pub struct ReaderProperties { | ||
codec_options: CodecOptions, | ||
read_bloom_filter: bool, | ||
|
@@ -835,7 +843,8 @@ impl ReaderProperties { | |
} | ||
} | ||
|
||
/// Reader properties builder. | ||
/// Builder for parquet file reader configuration. See example on | ||
/// [`ReaderProperties`] | ||
pub struct ReaderPropertiesBuilder { | ||
codec_options_builder: CodecOptionsBuilder, | ||
read_bloom_filter: Option<bool>, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the examples to the
WriterProperties
andReaderProperties
so they would be easier to findI think the module level docs now look pretty clear: