Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support peek_next_page() and skip_next_page in serialized_reader. #2044

Merged
merged 6 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion parquet/src/arrow/async_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ impl PageReader for InMemoryColumnChunkReader {
Ok(None)
}

fn peek_next_page(&self) -> Result<Option<PageMetadata>> {
fn peek_next_page(&mut self) -> Result<Option<PageMetadata>> {
Err(nyi_err!("https://github.com/apache/arrow-rs/issues/1792"))
}

Expand Down
2 changes: 1 addition & 1 deletion parquet/src/column/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ pub trait PageReader: Iterator<Item = Result<Page>> + Send {

/// Gets metadata about the next page, returns an error if no
/// column index information
fn peek_next_page(&self) -> Result<Option<PageMetadata>>;
fn peek_next_page(&mut self) -> Result<Option<PageMetadata>>;

/// Skips reading the next page, returns an error if no
/// column index information
Expand Down
22 changes: 21 additions & 1 deletion parquet/src/file/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ pub struct RowGroupMetaData {
num_rows: i64,
total_byte_size: i64,
schema_descr: SchemaDescPtr,
// Todo add filter result -> row range
page_offset_index: Option<Vec<Vec<PageLocation>>>,
}

impl RowGroupMetaData {
Expand Down Expand Up @@ -267,6 +267,11 @@ impl RowGroupMetaData {
self.columns.iter().map(|c| c.total_compressed_size).sum()
}

/// Returns reference of page offset index of all column in this row group.
pub fn page_offset_index(&self) -> &Option<Vec<Vec<PageLocation>>> {
&self.page_offset_index
}

/// Returns reference to a schema descriptor.
pub fn schema_descr(&self) -> &SchemaDescriptor {
self.schema_descr.as_ref()
Expand All @@ -277,6 +282,11 @@ impl RowGroupMetaData {
self.schema_descr.clone()
}

/// Sets page offset index for this row group.
pub fn set_page_offset(&mut self, page_offset: Vec<Vec<PageLocation>>) {
self.page_offset_index = Some(page_offset);
}

/// Method to convert from Thrift.
pub fn from_thrift(
schema_descr: SchemaDescPtr,
Expand All @@ -295,6 +305,7 @@ impl RowGroupMetaData {
num_rows,
total_byte_size,
schema_descr,
page_offset_index: None,
})
}

Expand All @@ -318,6 +329,7 @@ pub struct RowGroupMetaDataBuilder {
schema_descr: SchemaDescPtr,
num_rows: i64,
total_byte_size: i64,
page_offset_index: Option<Vec<Vec<PageLocation>>>,
}

impl RowGroupMetaDataBuilder {
Expand All @@ -328,6 +340,7 @@ impl RowGroupMetaDataBuilder {
schema_descr,
num_rows: 0,
total_byte_size: 0,
page_offset_index: None,
}
}

Expand All @@ -349,6 +362,12 @@ impl RowGroupMetaDataBuilder {
self
}

/// Sets page offset index for this row group.
pub fn set_page_offset(mut self, page_offset: Vec<Vec<PageLocation>>) -> Self {
self.page_offset_index = Some(page_offset);
self
}

/// Builds row group metadata.
pub fn build(self) -> Result<RowGroupMetaData> {
if self.schema_descr.num_columns() != self.columns.len() {
Expand All @@ -364,6 +383,7 @@ impl RowGroupMetaDataBuilder {
num_rows: self.num_rows,
total_byte_size: self.total_byte_size,
schema_descr: self.schema_descr,
page_offset_index: self.page_offset_index,
})
}
}
Expand Down
Loading