Skip to content

Commit 4272eb4

Browse files
authored
Always zero-copy from VortexBuffer to ArrowBuffer (#1348)
Previously we converted to ArrowBuffer via a Vec<u8>, which was only zero-copy if we had exclusive ownership of the underlying bytes. This uses a hard-to-find conversion from `bytes::Bytes` to `arrow_buffer::Bytes` which guarantees zero-copy.
1 parent dbbfd56 commit 4272eb4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

vortex-buffer/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ impl Buffer {
112112
pub fn into_arrow(self) -> ArrowBuffer {
113113
match self.0 {
114114
Inner::Arrow(a) => a,
115-
Inner::Bytes(b) => ArrowBuffer::from_vec(Vec::<u8>::from(b)),
115+
// This is cheeky. But it uses From<bytes::Bytes> for arrow_buffer::Bytes, even though
116+
// arrow_buffer::Bytes is only pub(crate). Seems weird...
117+
// See: https://github.com/apache/arrow-rs/issues/6033
118+
Inner::Bytes(b) => ArrowBuffer::from_bytes(b.into()),
116119
}
117120
}
118121
}

0 commit comments

Comments
 (0)