eliduvid commented on code in PR #12507:
URL: https://github.com/apache/arrow-rs/pull/12507#discussion_r4736737724
##########
parquet/src/column/writer/mod.rs:
##########
@@ -750,6 +750,68 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E>
{
)
}
+ /// Writes `num_levels` levels that all share the same definition level,
+ /// without requiring a materialized definition level buffer.
+ ///
+ /// This is equivalent to calling [`Self::write_batch_with_statistics`]
with
+ /// `def_levels` set to `num_levels` copies of `def_level` and no
repetition
+ /// levels, but avoids allocating and scanning that buffer. This is useful
+ /// for writing long runs of nulls, or of non-null values, into sparse
+ /// columns.
+ ///
+ /// If `def_level` equals the column's max definition level, `values` must
+ /// contain at least `num_levels` values. Otherwise every level is null and
+ /// no values are read.
+ ///
+ /// Returns the number of values written.
+ ///
+ /// `min`, `max` and `distinct_count` behave as in
+ /// [`Self::write_batch_with_statistics`].
+ ///
+ /// # Errors
+ ///
+ /// Returns an error if the column is repeated (max repetition level > 0),
+ /// or if `def_level` is negative or greater than the column's max
+ /// definition level.
+ pub fn write_batch_with_uniform_def_level(
+ &mut self,
+ values: &E::Values,
+ def_level: i16,
+ num_levels: usize,
+ min: Option<&E::T>,
+ max: Option<&E::T>,
+ distinct_count: Option<u64>,
+ ) -> Result<usize> {
+ if self.descr.max_rep_level() > 0 {
Review Comment:
1. I don't think we can support lists with more than one element here. Their
first element has rep_level 0 and the rest have 1, so it's never a uniform run.
2. Splitting it into two calls (first element, then the rest) doesn't work
either, because the second call would start in the middle of a row.
`write_batch_internal()` disallows that for a reason: a page can be closed
between calls, and pages must start at a row boundary.
3. What we can and I think should support is rows that are a single slot:
`null`, `[[[]]]`, `[[null]]`, or single-element lists like `[42]`. That only
needs passing rep_level 0 for every slot internally, no API change. If
multi-element lists are ever needed, that would be a separate new method, so
nothing here would need a breaking change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]