alamb commented on code in PR #11132: URL: https://github.com/apache/arrow-rs/pull/11132#discussion_r4097656029
########## parquet/tests/arrow_reader/custom_page_index_provider.rs: ########## @@ -0,0 +1,473 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! End-to-end test for custom PageIndexProvider implementation. +//! +//! This test validates reading with a custom PageIndexProvider through the +//! actual read path, ensuring that: +//! - Columns with page indexes use offset-index-driven fetch +//! - Columns without page indexes fall back to whole-column-chunk fetching +//! - Correct results are returned in both cases + +use arrow::compute::concat_batches; +use arrow_array::{Int32Array, RecordBatch, StringArray}; +use arrow_schema::{DataType, Field, Schema}; +use bytes::Bytes; +use parquet::DecodeResult; +use parquet::arrow::ArrowWriter; +use parquet::arrow::arrow_reader::{ + ArrowReaderMetadata, ArrowReaderOptions, ParquetRecordBatchReaderBuilder, RowSelection, + RowSelectionPolicy, +}; +use parquet::arrow::push_decoder::ParquetPushDecoderBuilder; +use parquet::file::metadata::page_index::PageIndexProvider; +use parquet::file::metadata::{PageIndexPolicy, ParquetMetaData}; +use parquet::file::page_index::column_index::ColumnIndexMetaData; +use parquet::file::page_index::index_reader::{decode_column_index, decode_offset_index}; +use parquet::file::page_index::offset_index::OffsetIndexMetaData; +use parquet::file::properties::{EnabledStatistics, WriterProperties}; +use std::collections::HashMap; +use std::ops::Range; +use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; + +#[test] +fn test_read_with_custom_page_index_provider_sync() { + run_test(Reader::Sync); +} + +#[test] +fn test_read_with_custom_page_index_provider_push() { + run_test(Reader::Push); +} + +#[cfg(feature = "async")] +#[test] +fn test_read_with_custom_page_index_provider_async() { + run_test(Reader::Async); +} + +#[derive(Debug, Clone, Copy)] +enum Reader { + Sync, + Push, + #[cfg(feature = "async")] + Async, +} + +/// Read `file` with `reader`, using `metadata` and `selection` +fn read( + reader: Reader, + file: Bytes, + metadata: ArrowReaderMetadata, + selection: RowSelection, + requested: &mut Vec<Range<u64>>, +) -> Vec<RecordBatch> { + match reader { + Reader::Sync => ParquetRecordBatchReaderBuilder::new_with_metadata(file, metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap() + .collect::<Result<_, _>>() + .unwrap(), + Reader::Push => { + let mut decoder = ParquetPushDecoderBuilder::new_with_metadata(metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap(); + let mut batches = vec![]; + loop { + match decoder.try_decode().unwrap() { + DecodeResult::NeedsData(ranges) => { + requested.extend(ranges.iter().cloned()); + let data = ranges + .iter() + .map(|r| file.slice(r.start as usize..r.end as usize)) + .collect(); + decoder.push_ranges(ranges, data).unwrap(); + } + DecodeResult::Data(batch) => batches.push(batch), + DecodeResult::Finished => return batches, + } + } + } + #[cfg(feature = "async")] + Reader::Async => { + use futures::TryStreamExt; + let input = std::io::Cursor::new(file.to_vec()); + let rt = tokio::runtime::Builder::new_current_thread() + .build() + .unwrap(); + rt.block_on(async { + parquet::arrow::ParquetRecordBatchStreamBuilder::new_with_metadata(input, metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap() + .try_collect() + .await + .unwrap() + }) + } + } +} + +fn run_test(reader: Reader) { + // Step 1: Write a parquet file with page indexes + let file_bytes = create_test_file(); + + // Step 2: Load metadata WITHOUT page indexes initially + let builder = ParquetRecordBatchReaderBuilder::try_new_with_options( + file_bytes.clone(), + ArrowReaderOptions::default().with_page_index_policy(PageIndexPolicy::Skip), + ) + .unwrap(); + + let metadata = builder.metadata().as_ref(); + + // Verify we have multiple row groups + assert_eq!(metadata.num_row_groups(), 3); + + // Step 3: Create a custom provider and populate it selectively + // Simulate a scenario where: + // - We only populate indexes for row groups 0 and 2 (skipping row group 1) + // - For row group 0: populate column 0 (id) and column 1 (value) + // - For row group 2: populate columns 0 (id) and 2 (name), so column 1 is a gap + let provider = SelectivePageIndexProvider::new( + file_bytes.clone(), + metadata, + &[(0, 0), (0, 1), (2, 0), (2, 2)], + ); + + // Step 4: Install the custom provider into metadata + let mut metadata_builder = metadata.clone().into_builder(); + metadata_builder = metadata_builder.set_page_index(Some(Arc::new(provider))); Review Comment: a minor usability thing -- it would be nice to have a `with` type method, so this could be ```rust let metadata_builder = metadata.clone() .into_builder() .with_page_index(Some(Arc::new(provider))); ``` But I don't think it is necessary ########## parquet/tests/arrow_reader/custom_page_index_provider.rs: ########## @@ -0,0 +1,473 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! End-to-end test for custom PageIndexProvider implementation. +//! +//! This test validates reading with a custom PageIndexProvider through the +//! actual read path, ensuring that: +//! - Columns with page indexes use offset-index-driven fetch +//! - Columns without page indexes fall back to whole-column-chunk fetching +//! - Correct results are returned in both cases + +use arrow::compute::concat_batches; +use arrow_array::{Int32Array, RecordBatch, StringArray}; +use arrow_schema::{DataType, Field, Schema}; +use bytes::Bytes; +use parquet::DecodeResult; +use parquet::arrow::ArrowWriter; +use parquet::arrow::arrow_reader::{ + ArrowReaderMetadata, ArrowReaderOptions, ParquetRecordBatchReaderBuilder, RowSelection, + RowSelectionPolicy, +}; +use parquet::arrow::push_decoder::ParquetPushDecoderBuilder; +use parquet::file::metadata::page_index::PageIndexProvider; +use parquet::file::metadata::{PageIndexPolicy, ParquetMetaData}; +use parquet::file::page_index::column_index::ColumnIndexMetaData; +use parquet::file::page_index::index_reader::{decode_column_index, decode_offset_index}; +use parquet::file::page_index::offset_index::OffsetIndexMetaData; +use parquet::file::properties::{EnabledStatistics, WriterProperties}; +use std::collections::HashMap; +use std::ops::Range; +use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; + +#[test] +fn test_read_with_custom_page_index_provider_sync() { + run_test(Reader::Sync); +} + +#[test] +fn test_read_with_custom_page_index_provider_push() { + run_test(Reader::Push); +} + +#[cfg(feature = "async")] +#[test] +fn test_read_with_custom_page_index_provider_async() { + run_test(Reader::Async); +} + +#[derive(Debug, Clone, Copy)] +enum Reader { + Sync, + Push, + #[cfg(feature = "async")] + Async, +} + +/// Read `file` with `reader`, using `metadata` and `selection` +fn read( + reader: Reader, + file: Bytes, + metadata: ArrowReaderMetadata, + selection: RowSelection, + requested: &mut Vec<Range<u64>>, +) -> Vec<RecordBatch> { + match reader { + Reader::Sync => ParquetRecordBatchReaderBuilder::new_with_metadata(file, metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap() + .collect::<Result<_, _>>() + .unwrap(), + Reader::Push => { + let mut decoder = ParquetPushDecoderBuilder::new_with_metadata(metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap(); + let mut batches = vec![]; + loop { + match decoder.try_decode().unwrap() { + DecodeResult::NeedsData(ranges) => { + requested.extend(ranges.iter().cloned()); + let data = ranges + .iter() + .map(|r| file.slice(r.start as usize..r.end as usize)) + .collect(); + decoder.push_ranges(ranges, data).unwrap(); + } + DecodeResult::Data(batch) => batches.push(batch), + DecodeResult::Finished => return batches, + } + } + } + #[cfg(feature = "async")] + Reader::Async => { + use futures::TryStreamExt; + let input = std::io::Cursor::new(file.to_vec()); + let rt = tokio::runtime::Builder::new_current_thread() + .build() + .unwrap(); + rt.block_on(async { + parquet::arrow::ParquetRecordBatchStreamBuilder::new_with_metadata(input, metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap() + .try_collect() + .await + .unwrap() + }) + } + } +} + +fn run_test(reader: Reader) { + // Step 1: Write a parquet file with page indexes + let file_bytes = create_test_file(); + + // Step 2: Load metadata WITHOUT page indexes initially + let builder = ParquetRecordBatchReaderBuilder::try_new_with_options( + file_bytes.clone(), + ArrowReaderOptions::default().with_page_index_policy(PageIndexPolicy::Skip), + ) + .unwrap(); + + let metadata = builder.metadata().as_ref(); + + // Verify we have multiple row groups + assert_eq!(metadata.num_row_groups(), 3); + + // Step 3: Create a custom provider and populate it selectively + // Simulate a scenario where: + // - We only populate indexes for row groups 0 and 2 (skipping row group 1) + // - For row group 0: populate column 0 (id) and column 1 (value) + // - For row group 2: populate columns 0 (id) and 2 (name), so column 1 is a gap + let provider = SelectivePageIndexProvider::new( + file_bytes.clone(), + metadata, + &[(0, 0), (0, 1), (2, 0), (2, 2)], + ); + + // Step 4: Install the custom provider into metadata + let mut metadata_builder = metadata.clone().into_builder(); + metadata_builder = metadata_builder.set_page_index(Some(Arc::new(provider))); + let metadata_with_custom_index = Arc::new(metadata_builder.build()); + + // Step 5: Create ArrowReaderMetadata with the custom page index + let arrow_metadata = ArrowReaderMetadata::try_new( + metadata_with_custom_index.clone(), + ArrowReaderOptions::default(), + ) + .unwrap(); + + // Step 6: Read data with RowSelection that triggers page skipping + + // Create a RowSelection that: + // - Selects rows 20-30 (in row group 0) + // - Selects rows 60-70 (in row group 1) + // - Selects rows 120-130 (in row group 2) + let selection = RowSelection::from(vec![ + // Skip first 20 rows + parquet::arrow::arrow_reader::RowSelector::skip(20), + // Select rows 20-30 + parquet::arrow::arrow_reader::RowSelector::select(10), + // Skip rows 30-60 + parquet::arrow::arrow_reader::RowSelector::skip(30), + // Select rows 60-70 + parquet::arrow::arrow_reader::RowSelector::select(10), + // Skip rows 70-120 + parquet::arrow::arrow_reader::RowSelector::skip(50), + // Select rows 120-130 + parquet::arrow::arrow_reader::RowSelector::select(10), + ]); + + // Collect all batches + let mut requested = Vec::<Range<u64>>::new(); + let batches = read( + reader, + file_bytes.clone(), + arrow_metadata, + selection, + &mut requested, + ); + + // Step 7: Check statistics + + // only the push test will populate requested + if matches!(reader, Reader::Push) { + let fetched = |rg: usize, col: usize| -> u64 { + let (start, len) = metadata.row_group(rg).column(col).byte_range(); + requested + .iter() + .filter(|r| r.start >= start && r.end <= start + len) + .map(|r| r.end - r.start) + .sum() + }; + let chunk_len = |rg: usize, col: usize| metadata.row_group(rg).column(col).byte_range().1; + assert!(fetched(0, 0) < chunk_len(0, 0)); // offset index: selected pages only + assert_eq!(fetched(0, 2), chunk_len(0, 2)); // no offset index: whole chunk + } + + // Note: We need to get the provider reference from the metadata to check stats + let provider_ref = metadata_with_custom_index Review Comment: It might be clearer to just keep this reference when it was first created, rather than trying to get it again ########## parquet/tests/arrow_reader/custom_page_index_provider.rs: ########## @@ -0,0 +1,473 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! End-to-end test for custom PageIndexProvider implementation. +//! +//! This test validates reading with a custom PageIndexProvider through the +//! actual read path, ensuring that: +//! - Columns with page indexes use offset-index-driven fetch +//! - Columns without page indexes fall back to whole-column-chunk fetching +//! - Correct results are returned in both cases + +use arrow::compute::concat_batches; +use arrow_array::{Int32Array, RecordBatch, StringArray}; +use arrow_schema::{DataType, Field, Schema}; +use bytes::Bytes; +use parquet::DecodeResult; +use parquet::arrow::ArrowWriter; +use parquet::arrow::arrow_reader::{ + ArrowReaderMetadata, ArrowReaderOptions, ParquetRecordBatchReaderBuilder, RowSelection, + RowSelectionPolicy, +}; +use parquet::arrow::push_decoder::ParquetPushDecoderBuilder; +use parquet::file::metadata::page_index::PageIndexProvider; +use parquet::file::metadata::{PageIndexPolicy, ParquetMetaData}; +use parquet::file::page_index::column_index::ColumnIndexMetaData; +use parquet::file::page_index::index_reader::{decode_column_index, decode_offset_index}; +use parquet::file::page_index::offset_index::OffsetIndexMetaData; +use parquet::file::properties::{EnabledStatistics, WriterProperties}; +use std::collections::HashMap; +use std::ops::Range; +use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; + +#[test] +fn test_read_with_custom_page_index_provider_sync() { + run_test(Reader::Sync); +} + +#[test] +fn test_read_with_custom_page_index_provider_push() { + run_test(Reader::Push); +} + +#[cfg(feature = "async")] +#[test] +fn test_read_with_custom_page_index_provider_async() { + run_test(Reader::Async); +} + +#[derive(Debug, Clone, Copy)] +enum Reader { + Sync, + Push, + #[cfg(feature = "async")] + Async, +} + +/// Read `file` with `reader`, using `metadata` and `selection` +fn read( + reader: Reader, + file: Bytes, + metadata: ArrowReaderMetadata, + selection: RowSelection, + requested: &mut Vec<Range<u64>>, +) -> Vec<RecordBatch> { + match reader { + Reader::Sync => ParquetRecordBatchReaderBuilder::new_with_metadata(file, metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap() + .collect::<Result<_, _>>() + .unwrap(), + Reader::Push => { + let mut decoder = ParquetPushDecoderBuilder::new_with_metadata(metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap(); + let mut batches = vec![]; + loop { + match decoder.try_decode().unwrap() { + DecodeResult::NeedsData(ranges) => { + requested.extend(ranges.iter().cloned()); + let data = ranges + .iter() + .map(|r| file.slice(r.start as usize..r.end as usize)) + .collect(); + decoder.push_ranges(ranges, data).unwrap(); + } + DecodeResult::Data(batch) => batches.push(batch), + DecodeResult::Finished => return batches, + } + } + } + #[cfg(feature = "async")] + Reader::Async => { + use futures::TryStreamExt; + let input = std::io::Cursor::new(file.to_vec()); + let rt = tokio::runtime::Builder::new_current_thread() + .build() + .unwrap(); + rt.block_on(async { + parquet::arrow::ParquetRecordBatchStreamBuilder::new_with_metadata(input, metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap() + .try_collect() + .await + .unwrap() + }) + } + } +} + +fn run_test(reader: Reader) { + // Step 1: Write a parquet file with page indexes + let file_bytes = create_test_file(); + + // Step 2: Load metadata WITHOUT page indexes initially + let builder = ParquetRecordBatchReaderBuilder::try_new_with_options( + file_bytes.clone(), + ArrowReaderOptions::default().with_page_index_policy(PageIndexPolicy::Skip), + ) + .unwrap(); + + let metadata = builder.metadata().as_ref(); + + // Verify we have multiple row groups + assert_eq!(metadata.num_row_groups(), 3); + + // Step 3: Create a custom provider and populate it selectively + // Simulate a scenario where: + // - We only populate indexes for row groups 0 and 2 (skipping row group 1) + // - For row group 0: populate column 0 (id) and column 1 (value) + // - For row group 2: populate columns 0 (id) and 2 (name), so column 1 is a gap + let provider = SelectivePageIndexProvider::new( + file_bytes.clone(), + metadata, + &[(0, 0), (0, 1), (2, 0), (2, 2)], + ); + + // Step 4: Install the custom provider into metadata + let mut metadata_builder = metadata.clone().into_builder(); + metadata_builder = metadata_builder.set_page_index(Some(Arc::new(provider))); + let metadata_with_custom_index = Arc::new(metadata_builder.build()); + + // Step 5: Create ArrowReaderMetadata with the custom page index + let arrow_metadata = ArrowReaderMetadata::try_new( + metadata_with_custom_index.clone(), + ArrowReaderOptions::default(), + ) + .unwrap(); + + // Step 6: Read data with RowSelection that triggers page skipping + + // Create a RowSelection that: + // - Selects rows 20-30 (in row group 0) + // - Selects rows 60-70 (in row group 1) + // - Selects rows 120-130 (in row group 2) + let selection = RowSelection::from(vec![ + // Skip first 20 rows + parquet::arrow::arrow_reader::RowSelector::skip(20), Review Comment: can we add a `use parquet::arrow::arrow_reader::RowSelector` to avoid the repetition here? ########## parquet/tests/arrow_reader/custom_page_index_provider.rs: ########## @@ -0,0 +1,473 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! End-to-end test for custom PageIndexProvider implementation. +//! +//! This test validates reading with a custom PageIndexProvider through the +//! actual read path, ensuring that: +//! - Columns with page indexes use offset-index-driven fetch +//! - Columns without page indexes fall back to whole-column-chunk fetching +//! - Correct results are returned in both cases + +use arrow::compute::concat_batches; +use arrow_array::{Int32Array, RecordBatch, StringArray}; +use arrow_schema::{DataType, Field, Schema}; +use bytes::Bytes; +use parquet::DecodeResult; +use parquet::arrow::ArrowWriter; +use parquet::arrow::arrow_reader::{ + ArrowReaderMetadata, ArrowReaderOptions, ParquetRecordBatchReaderBuilder, RowSelection, + RowSelectionPolicy, +}; +use parquet::arrow::push_decoder::ParquetPushDecoderBuilder; +use parquet::file::metadata::page_index::PageIndexProvider; +use parquet::file::metadata::{PageIndexPolicy, ParquetMetaData}; +use parquet::file::page_index::column_index::ColumnIndexMetaData; +use parquet::file::page_index::index_reader::{decode_column_index, decode_offset_index}; +use parquet::file::page_index::offset_index::OffsetIndexMetaData; +use parquet::file::properties::{EnabledStatistics, WriterProperties}; +use std::collections::HashMap; +use std::ops::Range; +use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; + +#[test] +fn test_read_with_custom_page_index_provider_sync() { + run_test(Reader::Sync); +} + +#[test] +fn test_read_with_custom_page_index_provider_push() { + run_test(Reader::Push); +} + +#[cfg(feature = "async")] +#[test] +fn test_read_with_custom_page_index_provider_async() { + run_test(Reader::Async); +} + +#[derive(Debug, Clone, Copy)] +enum Reader { + Sync, + Push, + #[cfg(feature = "async")] + Async, +} + +/// Read `file` with `reader`, using `metadata` and `selection` +fn read( + reader: Reader, + file: Bytes, + metadata: ArrowReaderMetadata, + selection: RowSelection, + requested: &mut Vec<Range<u64>>, +) -> Vec<RecordBatch> { + match reader { + Reader::Sync => ParquetRecordBatchReaderBuilder::new_with_metadata(file, metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap() + .collect::<Result<_, _>>() + .unwrap(), + Reader::Push => { + let mut decoder = ParquetPushDecoderBuilder::new_with_metadata(metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap(); + let mut batches = vec![]; + loop { + match decoder.try_decode().unwrap() { + DecodeResult::NeedsData(ranges) => { + requested.extend(ranges.iter().cloned()); + let data = ranges + .iter() + .map(|r| file.slice(r.start as usize..r.end as usize)) + .collect(); + decoder.push_ranges(ranges, data).unwrap(); + } + DecodeResult::Data(batch) => batches.push(batch), + DecodeResult::Finished => return batches, + } + } + } + #[cfg(feature = "async")] + Reader::Async => { + use futures::TryStreamExt; + let input = std::io::Cursor::new(file.to_vec()); + let rt = tokio::runtime::Builder::new_current_thread() + .build() + .unwrap(); + rt.block_on(async { + parquet::arrow::ParquetRecordBatchStreamBuilder::new_with_metadata(input, metadata) + .with_row_selection(selection) + .with_row_selection_policy(RowSelectionPolicy::Selectors) + .build() + .unwrap() + .try_collect() + .await + .unwrap() + }) + } + } +} + +fn run_test(reader: Reader) { + // Step 1: Write a parquet file with page indexes + let file_bytes = create_test_file(); + + // Step 2: Load metadata WITHOUT page indexes initially + let builder = ParquetRecordBatchReaderBuilder::try_new_with_options( + file_bytes.clone(), + ArrowReaderOptions::default().with_page_index_policy(PageIndexPolicy::Skip), + ) + .unwrap(); + + let metadata = builder.metadata().as_ref(); + + // Verify we have multiple row groups + assert_eq!(metadata.num_row_groups(), 3); + + // Step 3: Create a custom provider and populate it selectively + // Simulate a scenario where: + // - We only populate indexes for row groups 0 and 2 (skipping row group 1) + // - For row group 0: populate column 0 (id) and column 1 (value) + // - For row group 2: populate columns 0 (id) and 2 (name), so column 1 is a gap + let provider = SelectivePageIndexProvider::new( + file_bytes.clone(), + metadata, + &[(0, 0), (0, 1), (2, 0), (2, 2)], Review Comment: this is documented later on, but it would help me read this example if we could explain what these numbers represented something like ```rust // values are (row_group index, column index) &[(0, 0), (0, 1), (2, 0), (2, 2)], ``` -- 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]
