pub struct PreparedIpc(/* private fields */);Expand description
A prepared Arrow IPC fast-path encode.
Holds the computed layout and both framed message headers so the byte
length (byte_len) and the encode
(encode_into) share the work. A separate
ipc_fast_path_len + encode_ipc_into pair, by contrast, runs the
whole layout + flatbuffer build twice — once to size the sample and once to
fill it. On the per-output send path that redundant work is independent of
payload size, so it is a real fraction of the cost for high-frequency
small/medium messages.
The emitted bytes are identical to encode_ipc_into.
§Example
use dora_node_api::arrow_utils::decode_arrow_ipc;
use dora_node_api::arrow_utils::ipc_encode::PreparedIpc;
use dora_node_api::{IntoArrow, into_vec};
let data = vec![1u64, 2, 3].into_arrow();
// Prepare once, size the destination from `byte_len()`, then encode into it.
let prepared = PreparedIpc::new(&data).expect("primitive array is fast-path eligible");
let mut buffer = vec![0u8; prepared.byte_len()];
prepared.encode_into(&mut buffer)?;
// The buffer is a self-describing IPC stream, identical to `encode_ipc_into`.
let decoded = decode_arrow_ipc(&buffer)?;
assert_eq!(into_vec::<u64>(&decoded)?, vec![1, 2, 3]);Implementations§
Source§impl PreparedIpc
impl PreparedIpc
Sourcepub fn new(array: &DoraArray) -> Option<Self>
pub fn new(array: &DoraArray) -> Option<Self>
Prepare the fast-path encode for array, or None if array is not
fast-path eligible (fall back to encode_ipc_to_vec).
Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
Exact byte length of the IPC stream encode_into
writes. Use it to size the (shared-memory) destination sample.
Auto Trait Implementations§
impl Freeze for PreparedIpc
impl RefUnwindSafe for PreparedIpc
impl Send for PreparedIpc
impl Sync for PreparedIpc
impl Unpin for PreparedIpc
impl UnsafeUnpin for PreparedIpc
impl UnwindSafe for PreparedIpc
Blanket Implementations§
Source§impl<Source> AccessAs for Source
impl<Source> AccessAs for Source
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request