Skip to content

Commit

Permalink
Refactor out Bytes copy in Stripe footer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefffrey committed May 12, 2024
1 parent 4786e40 commit 1ee1df9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/stripe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Stripe {
let footer = reader
.get_bytes(info.footer_offset(), info.footer_length())
.context(IoSnafu)?;
let footer = Arc::new(deserialize_stripe_footer(&footer, compression)?);
let footer = Arc::new(deserialize_stripe_footer(footer, compression)?);

let columns = projected_data_type
.children()
Expand Down Expand Up @@ -161,7 +161,7 @@ impl Stripe {
.get_bytes(info.footer_offset(), info.footer_length())
.await
.context(IoSnafu)?;
let footer = Arc::new(deserialize_stripe_footer(&footer, compression)?);
let footer = Arc::new(deserialize_stripe_footer(footer, compression)?);

let columns = projected_data_type
.children()
Expand Down Expand Up @@ -243,13 +243,12 @@ impl StreamMap {
}
}

pub(crate) fn deserialize_stripe_footer(
bytes: &[u8],
fn deserialize_stripe_footer(
bytes: Bytes,
compression: Option<Compression>,
) -> Result<StripeFooter> {
let mut buffer = vec![];
// TODO: refactor to not need Bytes::copy_from_slice
Decompressor::new(Bytes::copy_from_slice(bytes), compression, vec![])
Decompressor::new(bytes, compression, vec![])
.read_to_end(&mut buffer)
.context(error::IoSnafu)?;
StripeFooter::decode(buffer.as_slice()).context(error::DecodeProtoSnafu)
Expand Down

0 comments on commit 1ee1df9

Please sign in to comment.