This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-12322-a5fb35542f17666cb9f1340e5592740e70fd333c in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
commit fb26b7560d9cb5248e651ed75d7a42f7222378c2 Author: siddu <[email protected]> AuthorDate: Tue Nov 24 20:05:34 2026 +0000 docs(parquet): document how page limits interact with write batch size (#12322) # Which issue does this PR close? - Closes #10931 # Rationale for this change The setters for the page limits already say they are best effort and that they are checked between batches, but how they relate to each other is only spelled out in one place, and that place does not cover the case this issue was filed about. A reader who lowers a page limit and still sees a larger page has to go read the column writer to find out why. This documents the behavior the writer has today. No pages are cut differently. # What changes are included in this PR? A "Page limits and batch size" section on `WriterProperties`. It explains that page limits are best effort, that `write_batch_size` is the granularity at which they are checked, and that a batch whose definition and repetition levels are all the same value is written at `data_page_row_count_limit` instead. Each of the four setters links to that section. It also fixes a duplicated "such as such as" in `set_write_batch_size`. # Are these changes tested? This is a documentation only change, so there is no behavior to test. The generated docs build without warnings from this file and the new links land on the new section. # Are there any significant user-facing changes? No. No API or behavior changes, only rustdoc text. # AI usage disclosure I used an AI assistant to draft the documentation change and this description. The parquet test suite and clippy were run locally before opening this PR. --- parquet/src/file/properties.rs | 46 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/parquet/src/file/properties.rs b/parquet/src/file/properties.rs index d98ea85c5b..3336f06367 100644 --- a/parquet/src/file/properties.rs +++ b/parquet/src/file/properties.rs @@ -229,6 +229,43 @@ enum OffsetIndexSetting { /// Some(Encoding::PLAIN) /// ); /// ``` +/// +/// # Page limits and batch size +/// +/// [`set_data_page_size_limit`](WriterPropertiesBuilder::set_data_page_size_limit), +/// [`set_data_page_row_count_limit`](WriterPropertiesBuilder::set_data_page_row_count_limit) +/// and [`set_dictionary_page_size_limit`](WriterPropertiesBuilder::set_dictionary_page_size_limit) +/// are best effort, so a page can end up larger than the limit set for it. Limits +/// are only checked between batches, and [`set_write_batch_size`](WriterPropertiesBuilder::set_write_batch_size) +/// sets how large those batches are. A page can therefore pass its limit by up to +/// one batch worth of data. Chunks also extend to record boundaries, so a column +/// with large repeated values can pass it by more than that. Lowering the write +/// batch size keeps pages closer to their limits. +/// +/// [`set_data_page_size_limit`](WriterPropertiesBuilder::set_data_page_size_limit) +/// can also make pages smaller than the row count limit alone would. When a batch +/// would not fit the byte budget the writer splits it further. For example, +/// a flat, non-null `INT64` column with dictionary encoding disabled and +/// `PLAIN` encoding can produce pages of about 1,250 rows at a 10,000 byte +/// page limit, even with a much larger write batch size. +/// +/// There is one exception to the batch size rule. When the definition and +/// repetition levels of a batch are all the same value, for example a nullable +/// column whose batch happens to contain no nulls, there is no level array to +/// split and a larger batch costs no extra work. Those batches are written +/// [`set_data_page_row_count_limit`](WriterPropertiesBuilder::set_data_page_row_count_limit) +/// rows at a time instead, so for them that limit is the base chunk size, +/// subject to further byte-budget splitting, and the write batch size does +/// not move page boundaries. +/// +/// Which of the two applies depends on the write path and on the data being +/// written, not only on the schema. The Arrow writer can pass levels in compact +/// form, while level slices supplied by the caller are always kept in full, so +/// `write_batch_size` keeps its usual effect on that path. Even within one path +/// the same column can be batched at either size, depending on whether a given +/// batch contains a null. A column with no level data at all, such as a +/// non-nullable flat column, always uses the write batch size as its base +/// chunk size, again subject to further byte-budget splitting. #[derive(Debug, Clone)] pub struct WriterProperties { write_batch_size: usize, @@ -755,6 +792,8 @@ impl WriterPropertiesBuilder { /// /// Note: this is a best effort limit based on value of /// [`set_write_batch_size`](Self::set_write_batch_size). + /// Batches with uniform level data are written at this limit instead of the + /// write batch size. See [page limits and batch size](WriterProperties#page-limits-and-batch-size). /// /// # Panics /// If the value is `0`. @@ -770,11 +809,14 @@ impl WriterPropertiesBuilder { /// For performance reasons, data for each column is written in /// batches of this size. /// - /// Additional limits such as such as + /// Additional limits such as /// [`set_data_page_row_count_limit`](Self::set_data_page_row_count_limit) /// are checked between batches, and thus the write batch size value acts as an /// upper-bound on the enforcement granularity of other limits. /// + /// Batches with uniform level data are written at the row count limit + /// instead. See [page limits and batch size](WriterProperties#page-limits-and-batch-size). + /// /// # Panics /// If the value is `0`. pub fn set_write_batch_size(mut self, value: usize) -> Self { @@ -1157,6 +1199,7 @@ impl WriterPropertiesBuilder { /// /// Note: this is a best effort limit based on value of /// [`set_write_batch_size`](Self::set_write_batch_size). + /// See [page limits and batch size](WriterProperties#page-limits-and-batch-size). pub fn set_dictionary_page_size_limit(mut self, value: usize) -> Self { self.default_column_properties .set_dictionary_page_size_limit(value); @@ -1173,6 +1216,7 @@ impl WriterPropertiesBuilder { /// /// Note: this is a best effort limit based on value of /// [`set_write_batch_size`](Self::set_write_batch_size). + /// See [page limits and batch size](WriterProperties#page-limits-and-batch-size). pub fn set_data_page_size_limit(mut self, value: usize) -> Self { self.default_column_properties .set_data_page_size_limit(value);
