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

[dnr] #31098

Closed
Closed

[dnr] #31098

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
37 changes: 12 additions & 25 deletions src/persist/src/azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,17 @@ impl Blob for AzureBlob {
};

let content_length = response.blob.properties.content_length;

// Here we're being quite defensive. If `content_length` comes back
// as 0 it's most likely incorrect. In that case we'll copy bytes
// of the network into a growable buffer, then copy the entire
// buffer into lgalloc.
let mut buffer = match content_length {
1.. => {
let region = self
.metrics
.lgbytes
.persist_azure
.new_region(usize::cast_from(content_length));
PreSizedBuffer::Sized(region)
}
0 => PreSizedBuffer::Unknown(Vec::new()),
};
tracing::debug!(
?key,
content_length = %response.blob.properties.content_length,
"blob response",
);

let mut buffer = self
.metrics
.lgbytes
.persist_azure
.new_region(usize::cast_from(content_length));

let mut body = response.data;
while let Some(value) = body.next().await {
Expand All @@ -233,15 +228,7 @@ impl Blob for AzureBlob {
})?;
buffer.extend_from_slice(&value);
}

// Spill our bytes to lgalloc, if they aren't already.
let lg_bytes = match buffer {
PreSizedBuffer::Sized(region) => LgBytes::from(Arc::new(region)),
PreSizedBuffer::Unknown(buffer) => {
self.metrics.lgbytes.persist_azure.try_mmap(buffer)
}
};
segments.push(MaybeLgBytes::LgBytes(lg_bytes));
segments.push(MaybeLgBytes::LgBytes(LgBytes::from(Arc::new(buffer))));
}

Ok(Some(SegmentedBytes::from(segments)))
Expand Down
Loading