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

Remove existing has_ methods for optional fields in ColumnChunkMetaData #1346

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Changes from all 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
17 changes: 3 additions & 14 deletions parquet/src/file/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,32 +428,21 @@ impl ColumnChunkMetaData {
self.data_page_offset
}

/// Returns `true` if this column chunk contains a index page, `false` otherwise.
pub fn has_index_page(&self) -> bool {
self.index_page_offset.is_some()
}

/// Returns the offset for the index page.
pub fn index_page_offset(&self) -> Option<i64> {
self.index_page_offset
}

/// Returns `true` if this column chunk contains a dictionary page, `false` otherwise.
pub fn has_dictionary_page(&self) -> bool {
self.dictionary_page_offset.is_some()
}

/// Returns the offset for the dictionary page, if any.
pub fn dictionary_page_offset(&self) -> Option<i64> {
self.dictionary_page_offset
}

/// Returns the offset and length in bytes of the column chunk within the file
pub fn byte_range(&self) -> (u64, u64) {
let col_start = if self.has_dictionary_page() {
self.dictionary_page_offset().unwrap()
} else {
self.data_page_offset()
let col_start = match self.dictionary_page_offset() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it matters at all, but just FYI you can also write this code like

let col_start = self.dictionary_page_offset()
  .unwrap_or(self.data_page_offset())

Which some might argue is more 'idomatic' rust

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay - I was out last week. Would you like me to send a refactor for this? :)

Copy link
Contributor

@alamb alamb Mar 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is up to you -- I always like to keep the code clean and small PRs to make it better are easy to approve and merge. However, there are only so many hours in a day :)

(welcome back BTW 👋 )

Some(dictionary_page_offset) => dictionary_page_offset,
None => self.data_page_offset(),
};
let col_len = self.compressed_size();
assert!(
Expand Down