pub struct PageIndexBuilder {
column_indexes: Option<ColumnChunkMap<ColumnIndexMetaData>>,
offset_indexes: Option<ColumnChunkMap<OffsetIndexMetaData>>,
}Expand description
Builder for constructing PageIndex structures
It supports:
- Populating column indexes for predicate columns (for page filtering)
- Populating offset indexes for projected columns (for direct I/O)
- Automatic conversion of empty structures to
Noneto save memory
Fields§
§column_indexes: Option<ColumnChunkMap<ColumnIndexMetaData>>§offset_indexes: Option<ColumnChunkMap<OffsetIndexMetaData>>Implementations§
Source§impl PageIndexBuilder
impl PageIndexBuilder
Sourcepub fn new(num_row_groups: usize, num_columns: usize) -> Self
pub fn new(num_row_groups: usize, num_columns: usize) -> Self
Creates a new PageIndexBuilder for the specified number of row groups and columns.
The dimensions are used to validate inserted coordinates. Storage is allocated only for
entries populated using
try_put_column_index and
try_put_offset_index.
§Panics
Panics if either dimension exceeds i32::MAX, the maximum collection size representable
by Thrift.
Use try_new for a fallible alternative.
Sourcepub fn try_new(num_row_groups: usize, num_columns: usize) -> Result<Self>
pub fn try_new(num_row_groups: usize, num_columns: usize) -> Result<Self>
Attempts to create a new PageIndexBuilder for the specified number of row groups and columns.
§Errors
Returns an error if either dimension exceeds i32::MAX, the maximum collection size
representable by Thrift.
Sourcepub(crate) fn new_from(page_index: PageIndex) -> Self
pub(crate) fn new_from(page_index: PageIndex) -> Self
Creates a new PageIndexBuilder from an existing PageIndex
This takes ownership of the index structures from the provided PageIndex,
allowing them to be modified and rebuilt. Useful for updating existing page indexes.
fn try_new_from(page_index: PageIndex) -> Result<Self>
Sourcepub fn allocate_column_indexes(
&mut self,
num_row_groups: usize,
num_columns: usize,
)
pub fn allocate_column_indexes( &mut self, num_row_groups: usize, num_columns: usize, )
Allocates space for column indexes
This replaces any existing column indexes with an empty sparse map having the specified
dimensions. It can then be populated using
try_put_column_index.
This can be used to add column index storage to a builder that lacks one
(either a Default builder, or one created from a PageIndex without column indexes).
§Panics
Panics if either dimension exceeds i32::MAX, the maximum collection size representable
by Thrift.
Use try_allocate_column_indexes for a
fallible alternative.
Sourcepub fn try_allocate_column_indexes(
&mut self,
num_row_groups: usize,
num_columns: usize,
) -> Result<()>
pub fn try_allocate_column_indexes( &mut self, num_row_groups: usize, num_columns: usize, ) -> Result<()>
Attempts to allocate space for column indexes
This is a fallible version of allocate_column_indexes.
§Errors
Returns an error if either dimension exceeds i32::MAX, the maximum collection size
representable by Thrift.
Sourcepub fn allocate_offset_indexes(
&mut self,
num_row_groups: usize,
num_columns: usize,
)
pub fn allocate_offset_indexes( &mut self, num_row_groups: usize, num_columns: usize, )
Allocates space for offset indexes
This replaces any existing offset indexes with an empty sparse map having the specified
dimensions. It can then be populated using
try_put_offset_index.
This can be used to add offset index storage to a builder that lacks one
(either a Default builder, or one created from a PageIndex without offset indexes).
§Panics
Panics if either dimension exceeds i32::MAX, the maximum collection size representable
by Thrift.
Use try_allocate_offset_indexes for a
fallible alternative.
Sourcepub fn try_allocate_offset_indexes(
&mut self,
num_row_groups: usize,
num_columns: usize,
) -> Result<()>
pub fn try_allocate_offset_indexes( &mut self, num_row_groups: usize, num_columns: usize, ) -> Result<()>
Attempts to allocate space for offset indexes
This is a fallible version of allocate_offset_indexes.
§Errors
Returns an error if either dimension exceeds i32::MAX, the maximum collection size
representable by Thrift.
Sourcepub fn put_column_index(
&mut self,
column_index: ColumnIndexMetaData,
row_group_idx: usize,
column_idx: usize,
)
👎Deprecated since 60.2.0: Use try_put_column_index to detect invalid coordinates or unavailable index storage
pub fn put_column_index( &mut self, column_index: ColumnIndexMetaData, row_group_idx: usize, column_idx: usize, )
Use try_put_column_index to detect invalid coordinates or unavailable index storage
Sets the column index for a specific row group and column
If column indexes were not allocated (see Self::allocate_column_indexes),
or the row group or column index is out of bounds, this method does nothing.
Sourcepub fn try_put_column_index(
&mut self,
column_index: ColumnIndexMetaData,
row_group_idx: usize,
column_idx: usize,
) -> Result<()>
pub fn try_put_column_index( &mut self, column_index: ColumnIndexMetaData, row_group_idx: usize, column_idx: usize, ) -> Result<()>
Attempts to set the column index for a specific row group and column.
§Errors
Returns an error, and drops column_index, if column indexes were not allocated or the
coordinate is out of bounds.
Sourcepub fn put_offset_index(
&mut self,
offset_index: OffsetIndexMetaData,
row_group_idx: usize,
column_idx: usize,
)
👎Deprecated since 60.2.0: Use try_put_offset_index to detect invalid coordinates or unavailable index storage
pub fn put_offset_index( &mut self, offset_index: OffsetIndexMetaData, row_group_idx: usize, column_idx: usize, )
Use try_put_offset_index to detect invalid coordinates or unavailable index storage
Sets the offset index for a specific row group and column
If offset indexes were not allocated (see Self::allocate_offset_indexes),
or the row group or column index is out of bounds, this method does nothing.
Sourcepub fn try_put_offset_index(
&mut self,
offset_index: OffsetIndexMetaData,
row_group_idx: usize,
column_idx: usize,
) -> Result<()>
pub fn try_put_offset_index( &mut self, offset_index: OffsetIndexMetaData, row_group_idx: usize, column_idx: usize, ) -> Result<()>
Attempts to set the offset index for a specific row group and column.
§Errors
Returns an error, and drops offset_index, if offset indexes were not allocated or the
coordinate is out of bounds.
Sourcefn is_empty_index<T>(index: Option<&ColumnChunkMap<T>>) -> bool
fn is_empty_index<T>(index: Option<&ColumnChunkMap<T>>) -> bool
Checks if an index structure is entirely empty.
Sourcepub fn build(self) -> PageIndex
pub fn build(self) -> PageIndex
Consumes the builder and returns a PageIndex
If an index structure was allocated but remains entirely empty (all entries are None),
it will be converted to None in the final PageIndex. This ensures that:
- Empty structures don’t consume memory unnecessarily
PageIndex::has_column_indexes()andPageIndex::has_offset_indexes()correctly returnfalsefor unpopulated indexes