pub struct PageIndex {
column_indexes: Option<ColumnChunkEntries<ColumnIndexMetaData>>,
offset_indexes: Option<ColumnChunkEntries<OffsetIndexMetaData>>,
}Expand description
Struct to encapsulate the Parquet Page Index
This struct provides a sparse, immutable representation of the Page Index, stored in row-major
order and keyed by row group and column index. It owns its populated column and offset index
metadata. Use Self::into_index_entries to move that metadata into an external cache.
It is used internally by this crate when assembling and writing the Page Index, and is the
default implementation of the PageIndexProvider contained in the ParquetMetaData.
§Example: Constructing a synthetic PageIndex
This example builds a ParquetMetaData for a file with a single row
group containing a single BYTE_ARRAY column with one data page, and
attaches a matching PageIndex, as might be done in tests that
exercise page-level statistics handling.
// Create metadata for a file with a single row group containing a
// single BYTE_ARRAY column "s" with three values
let file_metadata = FileMetaData::new(1, 3, None, None, schema, None);
let metadata = ParquetMetaData::new(file_metadata, vec![row_group]);
// Build a column index with min/max statistics for the single page
let mut column_index = ColumnIndexBuilder::new(PhysicalType::BYTE_ARRAY);
column_index.append(false, b"az".to_vec(), b"b".to_vec(), 0, None);
column_index.set_boundary_order(BoundaryOrder::ASCENDING);
let column_index = column_index.build().unwrap();
// Build an offset index recording the location of the single page
let mut offset_index = OffsetIndexBuilder::new();
offset_index.append_row_count(3);
offset_index.append_offset_and_size(4, 100);
let offset_index = offset_index.build();
// Assemble the PageIndex (one entry per row group, each with one
// entry per column) and attach it to the metadata
let mut page_index = PageIndexBuilder::try_new(1, 1).unwrap();
page_index
.try_put_column_index(column_index, 0, 0)
.unwrap();
page_index
.try_put_offset_index(offset_index, 0, 0)
.unwrap();
let page_index = page_index.build();
let metadata = metadata
.into_builder()
.set_page_index(Some(Arc::new(page_index)))
.build();
assert!(metadata.page_index().unwrap().is_complete());Fields§
§column_indexes: Option<ColumnChunkEntries<ColumnIndexMetaData>>§offset_indexes: Option<ColumnChunkEntries<OffsetIndexMetaData>>Implementations§
Source§impl PageIndex
impl PageIndex
pub(crate) fn try_new( column_indexes: Option<Vec<Vec<Option<ColumnIndexMetaData>>>>, offset_indexes: Option<Vec<Vec<Option<OffsetIndexMetaData>>>>, ) -> Result<Self>
pub(crate) fn from_entries( column_indexes: Option<ColumnChunkEntries<ColumnIndexMetaData>>, offset_indexes: Option<ColumnChunkEntries<OffsetIndexMetaData>>, ) -> Self
Sourcepub fn into_builder(self) -> PageIndexBuilder
pub fn into_builder(self) -> PageIndexBuilder
Convert this PageIndex into a PageIndexBuilder
Sourcepub fn try_into_builder(self) -> Result<PageIndexBuilder>
pub fn try_into_builder(self) -> Result<PageIndexBuilder>
Fallibly converts this PageIndex into a PageIndexBuilder.
Sourcepub fn into_index_entries(
self,
) -> (impl Iterator<Item = ((usize, usize), ColumnIndexMetaData)>, impl Iterator<Item = ((usize, usize), OffsetIndexMetaData)>)
pub fn into_index_entries( self, ) -> (impl Iterator<Item = ((usize, usize), ColumnIndexMetaData)>, impl Iterator<Item = ((usize, usize), OffsetIndexMetaData)>)
Consumes this page index and returns its populated column and offset index entries.
Each entry contains its (row_group_index, column_index) coordinate and owned index
metadata. This can be used to move parsed indexes into a cache without cloning their
metadata. Entries are returned in row-major order.
For an example of using this to populate an incremental page index
cache, see page_index_cache.rs
Trait Implementations§
Source§impl From<PageIndex> for PageIndexBuilder
impl From<PageIndex> for PageIndexBuilder
Source§impl PageIndexProvider for PageIndex
impl PageIndexProvider for PageIndex
Source§fn has_offset_indexes(&self) -> bool
fn has_offset_indexes(&self) -> bool
true if offset index structures are available via this provider Read moreSource§fn has_column_indexes(&self) -> bool
fn has_column_indexes(&self) -> bool
true if column index structures are available via this provider Read moreSource§fn column_index(
&self,
row_group_idx: usize,
column_idx: usize,
) -> Option<&ColumnIndexMetaData>
fn column_index( &self, row_group_idx: usize, column_idx: usize, ) -> Option<&ColumnIndexMetaData>
Source§fn offset_index(
&self,
row_group_idx: usize,
column_idx: usize,
) -> Option<&OffsetIndexMetaData>
fn offset_index( &self, row_group_idx: usize, column_idx: usize, ) -> Option<&OffsetIndexMetaData>
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
&dyn Any for downcasting Read moreSource§fn is_complete(&self) -> bool
fn is_complete(&self) -> bool
true if both the offset and column index structures are present Read more