Skip to main content

row_selection_from_row_ranges

Function row_selection_from_row_ranges 

Source
pub(crate) fn row_selection_from_row_ranges(
    row_ranges: impl Iterator<Item = Range<usize>>,
    total_row_count: usize,
) -> RowSelection
Expand description

Converts an iterator of row ranges into a RowSelection by creating a sequence of RowSelectors.

This function processes each range in the input and either creates a new selector or merges with the existing one, depending on whether the current range is contiguous with the preceding one or if there’s a gap that requires skipping rows. It handles both “select” and “skip” actions, optimizing the list of selectors by merging contiguous actions of the same type.

The returned selection intentionally stops at the end of the last matched range and may omit a trailing skip that would extend it to total_row_count. That is fine when the selection is used directly by the parquet reader, which simply stops once the selectors are exhausted.

Note: overlapping ranges are not supported and will result in an incorrect selection.