pub struct IpcWriteContext {
scratch: Vec<u8>,
reserve_scratch: bool,
fbb: FlatBufferBuilder<'static>,
lz4_block_size: Option<Lz4BlockSize>,
compressor: Option<Compressor<'static>>,
lz4_compressor: Option<Lz4Compressor>,
}Expand description
Additional context that may be needed for compression.
In the case of zstd, this will contain the zstd context, which can be reused between subsequent
compression calls to avoid the performance overhead of initialising a new context for every
compression. In the case of lz4, this will contain the lz4 frame encoder, whose hash table and
block buffers are likewise reused; its block size is configurable through
crate::writer::IpcWriteOptions::try_with_lz4_block_size. Also holds a [FlatBufferBuilder]
that is reused across IPC writes.
Fields§
§scratch: Vec<u8>§reserve_scratch: bool§fbb: FlatBufferBuilder<'static>§lz4_block_size: Option<Lz4BlockSize>The lz4 frame block size to build a cached encoder with; None selects the default.
compressor: Option<Compressor<'static>>§lz4_compressor: Option<Lz4Compressor>Implementations§
Source§impl IpcWriteContext
impl IpcWriteContext
Sourcepub(crate) fn mut_fbb(&mut self) -> &mut FlatBufferBuilder<'static>
pub(crate) fn mut_fbb(&mut self) -> &mut FlatBufferBuilder<'static>
Get a mutable reference to the [FlatBufferBuilder] that is reused across IPC writes.
Sourcepub fn set_reserve_scratch(&mut self, reserve: bool)
pub fn set_reserve_scratch(&mut self, reserve: bool)
Set whether the scratch buffer capacity should be reserved after each encode for reuse
on the next call. Set to false for the final batch in a sequence to avoid a
pointless allocation. by default, this is set to false.
Sourcepub(crate) fn reserve_scratch_with_capacity(&mut self, additional: usize)
pub(crate) fn reserve_scratch_with_capacity(&mut self, additional: usize)
Reserve the scratch buffer capacity for reuse on the next call. This is a no-op if
reserve_scratch is set to false.
pub(crate) fn scratch(&mut self) -> Vec<u8> ⓘ
Sourcepub(crate) fn set_lz4_block_size(&mut self, block_size: Lz4BlockSize)
pub(crate) fn set_lz4_block_size(&mut self, block_size: Lz4BlockSize)
Set the lz4 frame block size used by the cached lz4 encoder.
A cached encoder is dropped when the size changes so the next compression call builds one with the new block size.