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

Refactor stream retrieval and datatype iterators #36

Merged
merged 1 commit into from
Nov 12, 2023
Merged

Conversation

Jefffrey
Copy link
Collaborator

No description provided.

Comment on lines +890 to +894
pub fn get(&self, column: &Column, kind: Kind) -> Result<Decompressor> {
self.get_opt(column, kind).context(InvalidColumnSnafu {
name: column.name(),
})
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Instead of having to handle the case where column stream doesn't exist everywhere we call, just centralize the err here

Comment on lines +46 to +60
impl DirectBinaryIterator {
fn iter_next(&mut self) -> Result<Option<Vec<u8>>> {
let next = match self.lengths.next() {
Some(length) => Some(self.values.next(length? as usize)?.to_vec()),
None => None,
};
Ok(next)
}
}

impl Iterator for DirectBinaryIterator {
type Item = error::Result<Vec<u8>>;
type Item = Result<Vec<u8>>;

fn next(&mut self) -> Option<Self::Item> {
match self.lengths.next() {
Some(Ok(length)) => match self.values.next(length as usize) {
Ok(value) => Some(Ok(value.to_vec())),
Err(err) => Some(Err(err)),
},
Some(Err(err)) => Some(Err(err)),
None => None,
}
self.iter_next().transpose()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Idea of this pattern is to be able to utilize ? to simplify code a bit (no need to handle Some(Ok(length)) which then has to again match)

@@ -51,7 +51,7 @@ pub fn get_direct_signed_rle_reader<R: Read + Send + 'static>(
match column.encoding().kind() {
crate::proto::column_encoding::Kind::Direct => Ok(Box::new(SignedRleReaderV1::new(reader))),
crate::proto::column_encoding::Kind::DirectV2 => {
Ok(Box::new(RleReaderV2::try_new(reader, true, true)))
Ok(Box::new(RleReaderV2::new(reader, true, true)))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

try_new should only be used if returning a Result

@Jefffrey Jefffrey requested a review from WenyXu November 12, 2023 01:35
@Jefffrey Jefffrey merged commit a12cae7 into main Nov 12, 2023
6 checks passed
@Jefffrey Jefffrey deleted the refactoring_1 branch November 12, 2023 03:09
progval pushed a commit to progval/datafusion-orc that referenced this pull request Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants