[−][src]Struct binjs::io::entropy::rw::TableRefStreamState
State of a input/output stream of TableRef
.
Used to (de)serialize TableRef
, as the encoding of an TableRef
may depend on that of previous values.
Format
u32 representation: TableRef
interpretation
-
Next in Prelude
0
:TableRef::Prelude(prelude_latest + 1)
whereprelude_latest
is the latest prelude value encountered so far or -1 if no prelude value has been encountered yet
-
Recall Window Range [1, window_len] where
window_len
is the length of the window, specified when creating theTableRefStreamState
1
: Latest value2
: Second latest value- ...
window_len
: ...
-
Reference into Prelude Range: [window_len + 1, window_len + prelude_len] where
prelude_len
is the number of elements in the Prelude.window_len + 1
:TableRef::Prelude(0)
window_len + 2
:TableRef::Prelude(1)
- ...
-
Imported Reference into Shared Range: [window_len + prelude_len + 1, window_len + import_len], where
import_len
is the number of distinctTableRef::Shared
references encountere so far in the stream.window_len + prelude_len + 1
:TableRef::Shared(s1)
whereTableRef::Shared(s1)
was the firstTableRef::Shared
reference encountered in the streamwindow_len + prelude_len + 2
:TableRef::Shared(s2)
whereTableRef::Shared(s2)
was the firstTableRef::Shared
reference encountered in the stream and distinct froms1
window_len + prelude_len + 3
:TableRef::Shared(s3)
whereTableRef::Shared(s1)
was the firstTableRef::Shared
reference encountered in the stream and distinct froms1
,s2
, ...- ...
-
First-time Reference into Shared Range: [window_len + prelude_len + import_len + 1, ...[
window_len + prelude_len + import_len + 1
:TableRef::Shared(0)
window_len + prelude_len + import_len + 2
:TableRef::Shared(2)
- ...
Design notes
The main goals of this format are to:
- support both stream reading;
- expose wherever possible patterns that a stream compressor (e.g. brotli) can use to efficiently compress the stream.
Experiments show that the use of 0
and, for some streams, the Recall Window Range,
expose such useful patterns.
Experiments show that the dual Imported Shared References/First-time Shared References mechanism considerably decrease the sparsity of references into the shared dictionary. Where raw references into the shared dictionary are typically represented by a 3 bytes long varnum, consisting in unpredictable bytes, this mechanism tends to reduce them to varnums that may be represented with either 1 byte or 2 bytes with a small (hence easy to predict) first byte. In turn, this exposes patterns that the stream compressor may use efficiently.
Methods
impl<T> TableRefStreamState<T> where
T: Eq + Hash + Clone,
[src]
T: Eq + Hash + Clone,
pub fn new(
window_max_len: usize,
table: &LinearTable<T>
) -> TableRefStreamState<T>
[src]
window_max_len: usize,
table: &LinearTable<T>
) -> TableRefStreamState<T>
Create a new TableRefStreamState
.
window_max_len
represents the number of integers to reserve to
represent backreferences to values encountered recently.
pub fn from_u32(&mut self, value: u32) -> Option<TableRef>
[src]
Decode a TableRef
from a u32
.
pub fn into_u32(&mut self, value: TableRef) -> u32
[src]
Encode an TableRef
into a u32
.
This method does not perform any kind of sanity check on the TableRef
.
Trait Implementations
impl<T> Debug for TableRefStreamState<T> where
T: Debug,
[src]
T: Debug,
Auto Trait Implementations
impl<T> RefUnwindSafe for TableRefStreamState<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for TableRefStreamState<T> where
T: Send,
T: Send,
impl<T> Sync for TableRefStreamState<T> where
T: Sync,
T: Sync,
impl<T> Unpin for TableRefStreamState<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for TableRefStreamState<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
[src]
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
fn as_any(&self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> DowncastSync for T where
T: Send + Sync + Any,
[src]
T: Send + Sync + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,