Skip to main content

CompressionConfig

Struct CompressionConfig 

Source
pub struct CompressionConfig {
    pub min_array_length: usize,
    pub min_string_length: usize,
    pub min_frequency_count: u32,
    pub uuid_compression_potential: f32,
    pub min_net_savings: usize,
    pub delta_threshold: f32,
    pub min_delta_potential: f32,
    pub run_length_threshold: f32,
    pub min_compression_potential: f32,
    pub min_numeric_sequence_size: usize,
}
Expand description

Configuration constants for compression algorithms

Fields§

§min_array_length: usize

Minimum array length for pattern analysis

§min_string_length: usize

Minimum string length for dictionary inclusion

§min_frequency_count: u32

Minimum frequency for dictionary inclusion

§uuid_compression_potential: f32

Minimum compression potential for UUID patterns

§min_net_savings: usize

Minimum net wire-byte saving required to select CompressionStrategy::Dictionary (or the dictionary half of CompressionStrategy::Hybrid). The net saving is computed per candidate string as gain - cost, summed across all kept entries and reduced by a fixed metadata envelope, using the same size accounting the reported compressed_size uses. This makes dictionary selection a modelled net-positive decision, not a guarantee: see the known imprecisions below, which can make an accepted payload net-negative on adversarial input. The wire-byte report (compressed_size and everything derived from it) is unaffected and always measured, never modelled (see issue #333).

For a string of length L repeated c times with per-occurrence marker overhead m = 1 + decimal_digits(index) and per-entry dictionary-array cost L + 3 (the string, its quotes, one separator), an entry only pays off once c*(L-m) > L+3, i.e. L > (c*m + 3) / (c - 1). The smallest achievable m is 2 (index 0 is one decimal digit), so for c = 2 that means L > 7. "active" (L = 6, c = 2) fails this per-entry gate (gain 8 < cost 9) and is pruned before min_net_savings is consulted; a payload whose only repeated string is "active" yields an empty dictionary and CompressionStrategy::None. Even one kept entry rarely clears the floor alone: at c = 2 it needs L >= 27 to reach the default min_net_savings of 10 after the envelope.

Known imprecisions, both of which shift the modelled net toward being optimistic (a real payload can save fewer bytes than modelled, never more): this accounting does not model JSON string escaping inside dictionary strings (e.g. embedded quotes or backslashes), and it does not model the 1-byte-per-instance cost of escaping a payload string that legitimately starts with the sentinel byte (see substitute_dictionary_strings). Both are symmetric across ordinary payloads and shift the byte count only slightly, but a payload engineered to maximize sentinel-led strings can make a selected Dictionary strategy net-negative in the real, measured report.

§delta_threshold: f32

Threshold score for delta compression

§min_delta_potential: f32

Minimum delta potential for numeric compression

§run_length_threshold: f32

Threshold for run-length compression

§min_compression_potential: f32

Minimum compression potential for pattern selection

§min_numeric_sequence_size: usize

Minimum array size for numeric sequence analysis

Implementations§

Source§

impl CompressionConfig

Source

pub fn validate(&self) -> Result<(), ConfigError>

Validate compression configuration invariants.

§Errors

Returns ConfigError::InconsistentBounds when a potential/ratio field (uuid_compression_potential, min_delta_potential, min_compression_potential) is outside 0.0..=1.0, or when a threshold field (delta_threshold, run_length_threshold) is negative or non-finite.

§Examples
use pjson_rs::compression::CompressionConfig;

CompressionConfig::default().validate().expect("defaults are valid");

Trait Implementations§

Source§

impl Clone for CompressionConfig

Source§

fn clone(&self) -> CompressionConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompressionConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CompressionConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more