Skip to main content

PageIndex

Struct PageIndex 

Source
pub struct PageIndex {
    column_indexes: Option<Vec<Vec<Option<ColumnIndexMetaData>>>>,
    offset_indexes: Option<Vec<Vec<Option<OffsetIndexMetaData>>>>,
}
Expand description

Encapsulates the Parquet Page Index for efficient page-level data skipping

The Page Index is optional metadata that enables query engines to skip irrelevant data pages during scans, significantly improving I/O efficiency. It consists of two complementary structures:

  • ColumnIndex: Per-page min/max value boundaries that enable predicate-based page filtering. Allows determining which pages might contain rows matching a query predicate without reading the actual data pages.

  • OffsetIndex: Physical locations and sizes of data pages, plus the first row index of each page. Used to locate and read only the pages identified as relevant by the ColumnIndex.

Together, these indexes enable:

  • Single-row lookups reading only one data page per column (on sorted columns)
  • Range scans reading only pages containing values in the query range
  • Efficient cross-column filtering by skipping corresponding row ranges

§Structure

Within a Parquet file, both indexes are organized as a two-level structure, with indexes arranged first by row group, and then column. The ColumnChunkMetaData contains pointers to the indexes for a given column chunk, so they may be populated piecemeal. This struct allows access either by row group index (Self::column_indexes_for_rowgroup, Self::offset_indexes_for_rowgroup) or individual access by row group index and column number (Self::column_index, Self::offset_index).

Each entry is Option<T> because:

  • The entire page index might be absent (old files, disabled during write)
  • Individual columns might lack indexes (unsupported types, statistics disabled)

§Example: Checking if Page Index is Available

use parquet::file::metadata::ParquetMetaData;

fn check_page_index_availability(metadata: &ParquetMetaData) -> Result<()> {
    if let Some(page_index) = metadata.page_index() {
        println!("Page index present:");
        println!("  Has offset indexes: {}", page_index.has_offset_indexes());
        println!("  Has column indexes: {}", page_index.has_column_indexes());

        // Check availability for first row group, first column
        if let Some(col_idx) = page_index.column_index(0, 0) {
            println!("  Column index found for row group 0, column 0");
            println!("    Number of pages: {}", col_idx.num_pages());
        }

        if let Some(offset_idx) = page_index.offset_index(0, 0) {
            println!("  Offset index found for row group 0, column 0");
            println!("    Number of pages: {}", offset_idx.page_locations().len());
        }
    } else {
        println!("No page index available");
    }
    Ok(())
}

§Example: Using Page Index for Predicate Pushdown

use parquet::file::metadata::ParquetMetaData;
use parquet::file::page_index::column_index::ColumnIndexMetaData;

/// Identifies which pages in a column might contain values >= min_value
fn find_relevant_pages(
    metadata: &ParquetMetaData,
    row_group_idx: usize,
    column_idx: usize,
    min_value: i32,
) -> Vec<usize> {
    let mut relevant_pages = Vec::new();

    let Some(page_index) = metadata.page_index() else {
        // No page index - must read all pages
        return relevant_pages;
    };

    let Some(column_index) = page_index.column_index(row_group_idx, column_idx) else {
        // No column index - must read all pages
        return relevant_pages;
    };

    // Check each page's statistics
    match column_index {
        ColumnIndexMetaData::INT32(index) => {
            for (page_num, max_value) in index.max_values_iter().enumerate() {
                // Page might contain matching rows if its max >= our min
                if let Some(max) = max_value {
                    if *max >= min_value {
                        relevant_pages.push(page_num);
                    }
                }
            }
        }
        _ => {
            // Wrong column type - read all pages
        }
    }

    relevant_pages
}

Fields§

§column_indexes: Option<Vec<Vec<Option<ColumnIndexMetaData>>>>§offset_indexes: Option<Vec<Vec<Option<OffsetIndexMetaData>>>>

Implementations§

Source§

impl PageIndex

Source

pub(crate) fn new( column_indexes: Option<Vec<Vec<Option<ColumnIndexMetaData>>>>, offset_indexes: Option<Vec<Vec<Option<OffsetIndexMetaData>>>>, ) -> Self

Source

pub fn has_offset_indexes(&self) -> bool

Returns true if offset index structures are present

This indicates whether OffsetIndexMetaData structures were loaded or created. Returns true even if some individual columns lack offset indexes.

To check if a specific column has an offset index, use Self::offset_index.

Source

pub fn has_column_indexes(&self) -> bool

Returns true if column index structures are present

This indicates whether ColumnIndexMetaData structures were loaded or created. Returns true even if some individual columns lack column indexes.

To check if a specific column has a column index, use Self::column_index.

Source

pub fn is_complete(&self) -> bool

Returns true if both the offset and column index structures are present

This is equivalent to both Self::has_offset_indexes and Self::has_column_indexes returning true.

Source

pub fn column_indexes_for_rowgroup( &self, row_group_idx: usize, ) -> Option<&[Option<ColumnIndexMetaData>]>

Returns column indexes for all columns in the specified row group

Returns None if:

  • Column indexes were not loaded or are not available
  • The row group index is out of bounds

Returns Some(&[Option<ColumnIndexMetaData>]) where:

  • The slice length equals the number of columns in the row group
  • Each element is Some if that column has statistics, None otherwise
Source

pub fn column_index( &self, row_group_idx: usize, column_idx: usize, ) -> Option<&ColumnIndexMetaData>

Returns the column index for a specific row group and column

This is the primary method for accessing page-level min/max statistics used in predicate pushdown and page skipping optimizations.

Returns:

  • Some(&ColumnIndexMetaData) - Column index is available with statistics
  • None - Index unavailable (not loaded, row group/column out of bounds, or no statistics)
Source

pub fn offset_indexes_for_rowgroup( &self, row_group_idx: usize, ) -> Option<&[Option<OffsetIndexMetaData>]>

Returns offset indexes for all columns in the specified row group

Returns None if:

  • Offset indexes were not loaded or are not available
  • The row group index is out of bounds

Returns Some(&[Option<OffsetIndexMetaData>]) where:

  • The slice length equals the number of columns in the row group
  • Each element is Some if that column has location metadata, None otherwise
Source

pub fn offset_index( &self, row_group_idx: usize, column_idx: usize, ) -> Option<&OffsetIndexMetaData>

Returns the offset index for a specific row group and column

This provides physical locations and sizes of data pages, enabling:

  • Direct seeking to specific pages identified by column index filtering
  • Reading only relevant pages without scanning entire column chunks
  • Efficient cross-column row-based filtering

Returns:

  • Some(&OffsetIndexMetaData) - Offset index is available
  • None - Index unavailable (not loaded, row group/column out of bounds)
Source

pub fn num_data_pages( &self, row_group_idx: usize, column_idx: usize, ) -> Option<usize>

Returns the expected number of data pages for a specific column chunk

This count includes only data pages, not dictionary pages or other metadata pages.

Returns:

  • Some(usize) - Number of data pages if any index is available
  • None - No index information available for this column
Source

pub fn page_locations( &self, row_group_idx: usize, column_idx: usize, ) -> Option<&Vec<PageLocation>>

Returns the physical locations of all data pages in a column chunk

Each PageLocation contains:

  • File offset where the page begins
  • Compressed size of the page
  • First row index within the row group

This enables direct I/O to specific pages without reading the entire column chunk.

Returns:

  • Some(&Vec<PageLocation>) - Vector of page locations if offset index exists
  • None - Offset index not available

Trait Implementations§

Source§

impl Clone for PageIndex

Source§

fn clone(&self) -> PageIndex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PageIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl HeapSize for PageIndex

Source§

fn heap_size(&self) -> usize

Return the size of any bytes allocated on the heap by this object, including heap memory in those structures Read more
Source§

impl PartialEq for PageIndex

Source§

fn eq(&self, other: &PageIndex) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PageIndex

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Ungil for T
where T: Send,