pub struct SequenceReplay<'s> { /* private fields */ }Expand description
A Matcher that reports a given parse instead of searching, so the
ordinary block pipeline builds a frame from it (C
ZSTD_compressSequences). The parse is consumed as blocks are cut:
wherever the encoder ends a block, a sequence running across the cut is
split there, and a match piece shorter than MIN_MATCH goes out as
literals. Block delimiters, if any, end blocks: each delimited region is
a block of its own, cut further only where it exceeds the block size.
The parse should pass validate_parse: offsets are taken as given.
use structured_zstd::encoding::sequences::{ExternalSequence, SequenceReplay};
use structured_zstd::encoding::{CompressionLevel, FrameCompressor};
let input = b"abcabcabcabc";
let parse = [ExternalSequence { offset: 3, lit_len: 3, match_len: 9, rep: 0 }];
let replay = SequenceReplay::new(&parse, 1 << 10);
let mut frame = Vec::new();
let mut compressor = FrameCompressor::new_with_matcher(replay, CompressionLevel::Default);
compressor.set_source(&input[..]);
compressor.set_drain(&mut frame);
compressor.compress();Implementations§
Source§impl<'s> SequenceReplay<'s>
impl<'s> SequenceReplay<'s>
Sourcepub fn new(sequences: &'s [ExternalSequence], window_size: u64) -> Self
pub fn new(sequences: &'s [ExternalSequence], window_size: u64) -> Self
Replay sequences into frames whose window is window_size bytes,
which every offset must respect.
Sourcepub fn with_dictionary(self) -> Self
pub fn with_dictionary(self) -> Self
Let the frame use the compressor’s dictionary: its ID goes in the header and its entropy and repeat offsets seed the first block, so offsets may reach into its content.
Trait Implementations§
Source§impl Matcher for SequenceReplay<'_>
impl Matcher for SequenceReplay<'_>
Source§fn fixed_block_len(&self) -> Option<usize>
fn fixed_block_len(&self) -> Option<usize>
The rest of the region up to the next block delimiter, skipping regions with nothing in them.
Source§fn get_last_space(&mut self) -> &[u8] ⓘ
fn get_last_space(&mut self) -> &[u8] ⓘ
commit_filled.Source§fn fill_in_place(
&mut self,
capacity: usize,
fill: &mut dyn FnMut(&mut HistoryBuf) -> (usize, bool),
) -> (usize, bool)
fn fill_in_place( &mut self, capacity: usize, fill: &mut dyn FnMut(&mut HistoryBuf) -> (usize, bool), ) -> (usize, bool)
Source§fn uncommitted_input(&self) -> &[u8] ⓘ
fn uncommitted_input(&self) -> &[u8] ⓘ
fill_in_place that no block has
claimed yet.Source§fn commit_filled(&mut self, len: usize)
fn commit_filled(&mut self, len: usize)
len bytes from the head of
uncommitted_input as the next block.Source§fn skip_matching(&mut self)
fn skip_matching(&mut self)
Source§fn start_matching(&mut self, handle_sequence: impl FnMut(Sequence))
fn start_matching(&mut self, handle_sequence: impl FnMut(Sequence))
Sequence).Source§fn reset(&mut self, _level: CompressionLevel)
fn reset(&mut self, _level: CompressionLevel)
Source§fn supports_dictionary_priming(&self) -> bool
fn supports_dictionary_priming(&self) -> bool
false for custom matchers.Source§fn window_size(&self) -> u64
fn window_size(&self) -> u64
Source§fn skip_matching_with_hint(&mut self, _incompressible_hint: Option<bool>)
fn skip_matching_with_hint(&mut self, _incompressible_hint: Option<bool>)
Source§fn set_source_size_hint(&mut self, _size: u64)
fn set_source_size_hint(&mut self, _size: u64)
Source§fn set_dictionary_size_hint(&mut self, _sizes: DictionarySizes)
fn set_dictionary_size_hint(&mut self, _sizes: DictionarySizes)
ZSTD_createCDict, keyed by the
serialized size) and sizes its dictionary tables from the content.
Default no-op for custom matchers and test stubs; consumed at the next
reset.Source§fn clear_param_overrides(&mut self)
fn clear_param_overrides(&mut self)
reset. Called by
FrameCompressor::set_compression_level
so switching back to a bare level after a customized frame does not
keep the old overrides sticky. Default no-op for custom matchers.Source§fn prime_with_dictionary(
&mut self,
_dict_content: &[u8],
_offset_hist: [u32; 3],
)
fn prime_with_dictionary( &mut self, _dict_content: &[u8], _offset_hist: [u32; 3], )
Source§fn dictionary_is_resident(&self) -> bool
fn dictionary_is_resident(&self) -> bool
reset re-borrowed a resident
attach-mode dictionary (kept the dict bytes + cached index in place).
When true the caller MUST skip Self::prime_with_dictionary and only
reapply the offset history via Self::reapply_resident_dictionary.Source§fn reapply_resident_dictionary(&mut self, _offset_hist: [u32; 3])
fn reapply_resident_dictionary(&mut self, _offset_hist: [u32; 3])
Source§fn restore_primed_dictionary(&mut self, _level: CompressionLevel) -> bool
fn restore_primed_dictionary(&mut self, _level: CompressionLevel) -> bool
Self::capture_primed_dictionary
at the SAME level (a table copy) instead of re-running
Self::prime_with_dictionary (which re-hashes every dictionary
position). Returns true when a matching snapshot was restored;
false (the default) means the caller must prime then capture.Source§fn capture_primed_dictionary(&mut self, _level: CompressionLevel)
fn capture_primed_dictionary(&mut self, _level: CompressionLevel)
Self::restore_primed_dictionary it. Default no-op.Source§fn invalidate_primed_dictionary(&mut self)
fn invalidate_primed_dictionary(&mut self)
Source§fn seed_dictionary_entropy(
&mut self,
_huff: Option<&HuffmanTable>,
_ll: Option<&FSETable>,
_ml: Option<&FSETable>,
_of: Option<&FSETable>,
)
fn seed_dictionary_entropy( &mut self, _huff: Option<&HuffmanTable>, _ll: Option<&FSETable>, _ml: Option<&FSETable>, _of: Option<&FSETable>, )
Source§fn block_samples_match_dict(&self, _block: &[u8]) -> bool
fn block_samples_match_dict(&self, _block: &[u8]) -> bool
block hashes to a match in an attached dictionary.
The raw-fast-path uses this to avoid skipping the scan on a block that
looks incompressible but compresses against the dictionary (an external
match the block’s own content cannot reveal). Defaults to false for
custom matchers (and the no-dict case), leaving the content-only verdict.Source§fn matches_beyond_window_tables(&self) -> bool
fn matches_beyond_window_tables(&self) -> bool
false.Source§fn settle_block_cut(&mut self, window: usize, cut: usize) -> usize
fn settle_block_cut(&mut self, window: usize, cut: usize) -> usize
cut bytes into the window bytes of
uncommitted_input it looked at. A matcher
that already knows a match crossing the cut moves it out of the match,
at most to window; cutting inside one only makes the next block
start by repeating it. Defaults to cut.