-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
pub fn get(&self, column: &Column, kind: Kind) -> Result<Decompressor> { | ||
self.get_opt(column, kind).context(InvalidColumnSnafu { | ||
name: column.name(), | ||
}) | ||
} |
There was a problem hiding this comment.
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
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() |
There was a problem hiding this comment.
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))) |
There was a problem hiding this comment.
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
Feature/fix datatypes
No description provided.