alamb commented on code in PR #5538:
URL: https://github.com/apache/arrow-rs/pull/5538#discussion_r1567573427
##########
object_store/src/upload.rs:
##########
@@ -157,19 +159,34 @@ impl WriteMultipart {
/// [`Self::wait_for_capacity`] prior to calling this method
pub fn write(&mut self, mut buf: &[u8]) {
while !buf.is_empty() {
- let capacity = self.buffer.capacity();
- let remaining = capacity - self.buffer.len();
+ let remaining = self.chunk_size - self.buffer.content_length();
let to_read = buf.len().min(remaining);
self.buffer.extend_from_slice(&buf[..to_read]);
if to_read == remaining {
- let part = std::mem::replace(&mut self.buffer,
Vec::with_capacity(capacity));
- self.put_part(part.into())
+ let buffer = std::mem::take(&mut self.buffer);
+ self.put_part(buffer.into())
}
buf = &buf[to_read..]
}
}
- fn put_part(&mut self, part: Bytes) {
+ /// Put a chunk of data into this [`WriteMultipart`]
+ ///
+ /// See [`Self::write`] for information on backpressure
+ pub fn put(&mut self, mut bytes: Bytes) {
Review Comment:
this would be great to include in the docs as I found it non obvious.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]