JakeDern commented on code in PR #10128:
URL: https://github.com/apache/arrow-rs/pull/10128#discussion_r3839982625
##########
arrow-ipc/src/writer.rs:
##########
@@ -271,31 +269,37 @@ impl<T: IpcMessageSink + ?Sized> IpcMessageSinkExt for T
{}
/// Optional hot-path hook for record batch messages.
trait IpcRecordBatchSink: IpcMessageSinkExt {
- /// Writes a record batch message from its encoded metadata and body
buffers.
+ /// Writes a record batch (or dictionary batch) message from its encoded
+ /// metadata and body buffers.
+ ///
+ /// `metadata` is the raw flatbuffer [`crate::Message`] (without
continuation
+ /// prefix), borrowed from the reused [`FlatBufferBuilder`]. The body
buffers are
+ /// already materialized as [`EncodedBuffer`] segments, allowing buffer
output to
+ /// preserve uncompressed Arrow buffers. They are drained out of
+ /// `encoded_buffers` so the caller can reuse its allocation.
+ ///
+ /// Each body buffer is padded to the alignment as it is written, so the
body
+ /// needs no trailing padding.
///
- /// The body buffers are already materialized as [`EncodedBuffer`]
segments,
- /// allowing buffer output to preserve uncompressed Arrow buffers.
/// Returns the padded metadata length and body length written.
fn write_record_batch(
&mut self,
- metadata: Vec<u8>,
- encoded_buffers: Vec<EncodedBuffer>,
+ metadata: &[u8],
+ encoded_buffers: &mut Vec<EncodedBuffer>,
body_len: usize,
- tail_pad: usize,
write_options: &IpcWriteOptions,
) -> Result<(usize, usize), ArrowError> {
let alignment = write_options.alignment;
let layout = MetadataLayout::new(metadata.len(), write_options);
self.write_continuation(write_options, layout.padded_metadata_len as
i32)?;
- self.write_vec(metadata)?;
+ self.write_slice(metadata)?;
self.write_padding(layout.metadata_padding)?;
- for enc in encoded_buffers {
+ for enc in encoded_buffers.drain(..) {
Review Comment:
`write_encoded_buffer` wants ownership
--
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]