Skip to main content

ParquetRecordBatchReaderBuilder

Type Alias ParquetRecordBatchReaderBuilder 

Source
pub type ParquetRecordBatchReaderBuilder<T> = ArrowReaderBuilder<SyncReader<T>>;
Expand description

Creates ParquetRecordBatchReader for reading Parquet files into Arrow [RecordBatch]es

§See Also

Aliased Type§

pub struct ParquetRecordBatchReaderBuilder<T> {
Show 13 fields pub(crate) input: SyncReader<T>, pub(crate) metadata: Arc<ParquetMetaData>, pub(crate) schema: Arc<Schema>, pub(crate) fields: Option<Arc<ParquetField>>, pub(crate) batch_size: usize, pub(crate) row_group_plan: RowGroupPlan, pub(crate) projection: ProjectionMask, pub(crate) filter: Option<RowFilter>, pub(crate) row_selection_policy: RowSelectionPolicy, pub(crate) limit: Option<usize>, pub(crate) offset: Option<usize>, pub(crate) metrics: ArrowReaderMetrics, pub(crate) max_predicate_cache_size: usize,
}

Fields§

§input: SyncReader<T>

The “input” to read parquet data from.

Note in the case of the ParquetPushDecoderBuilder there is no underlying reader; the input is instead PushDecoderInput, the buffer that caller-pushed bytes accumulate in.

§metadata: Arc<ParquetMetaData>§schema: Arc<Schema>§fields: Option<Arc<ParquetField>>§batch_size: usize§row_group_plan: RowGroupPlan§projection: ProjectionMask§filter: Option<RowFilter>§row_selection_policy: RowSelectionPolicy§limit: Option<usize>§offset: Option<usize>§metrics: ArrowReaderMetrics§max_predicate_cache_size: usize

Implementations§

Source§

impl<T: ChunkReader + 'static> ParquetRecordBatchReaderBuilder<T>

Source

pub fn try_new(reader: T) -> Result<Self>

Create a new ParquetRecordBatchReaderBuilder

// Build the reader from anything that implements `ChunkReader`
// such as a `File`, or `Bytes`
let mut builder = ParquetRecordBatchReaderBuilder::try_new(file).unwrap();
// The builder has access to ParquetMetaData such
// as the number and layout of row groups
assert_eq!(builder.metadata().num_row_groups(), 1);
// Call build to create the reader
let mut reader: ParquetRecordBatchReader = builder.build().unwrap();
// Read data
while let Some(batch) = reader.next().transpose()? {
    println!("Read {} rows", batch.num_rows());
}
Source

pub fn try_new_with_options( reader: T, options: ArrowReaderOptions, ) -> Result<Self>

Create a new ParquetRecordBatchReaderBuilder with ArrowReaderOptions

Use this method if you want to control the options for reading the ParquetMetaData

Source

pub fn new_with_metadata(input: T, metadata: ArrowReaderMetadata) -> Self

Create a ParquetRecordBatchReaderBuilder from the provided ArrowReaderMetadata

Use this method if you already have ParquetMetaData for a file. This interface allows:

  1. Loading metadata once and using it to create multiple builders with potentially different settings or run on different threads

  2. Using a cached copy of the metadata rather than re-reading it from the file each time a reader is constructed.

See the docs on ArrowReaderMetadata for more details

§Example
let metadata = ArrowReaderMetadata::load(&file, Default::default()).unwrap();
let mut a = ParquetRecordBatchReaderBuilder::new_with_metadata(file.clone(), metadata.clone()).build().unwrap();
let mut b = ParquetRecordBatchReaderBuilder::new_with_metadata(file, metadata).build().unwrap();

// Should be able to read from both in parallel
assert_eq!(a.next().unwrap().unwrap(), b.next().unwrap().unwrap());
Source

pub fn get_row_group_column_bloom_filter( &self, row_group_idx: usize, column_idx: usize, ) -> Result<Option<Sbbf>>

Read bloom filter for a column in a row group

Returns None if the column does not have a bloom filter

We should call this function after other forms pruning, such as projection and predicate pushdown.

Source

pub fn build(self) -> Result<ParquetRecordBatchReader>

Build a ParquetRecordBatchReader

Note: this will eagerly evaluate any RowFilter before returning