pub struct Compressor<T: NumberLike>(_);
Expand description

Converts vectors of numbers into compressed bytes for use in a wrapping columnar data format.

All compressor methods leave its state unchanged if they return an error. You can configure behavior like compression level by instantiating with .from_config()

You can use the wrapped compressor at a data page level.

Implementations§

source§

impl<T: NumberLike> Compressor<T>

source

pub fn from_config(config: CompressorConfig) -> Self

Creates a new compressor, given a CompressorConfig. Internally, the compressor builds Flags as well as an internal configuration that doesn’t show up in the output file. You can inspect the flags it chooses with .flags().

source

pub fn flags(&self) -> &Flags

Returns a reference to the compressor’s flags.

source

pub fn header(&mut self) -> QCompressResult<()>

Writes out a header using the compressor’s data type and flags. Will return an error if the compressor has already written the header.

Each .qco file must start with such a header, which contains:

  • a 4-byte magic header for “qco!” in ascii,
  • a byte for the data type (e.g. i64 has byte 1 and f64 has byte 5), and
  • bytes for the flags used to compress.
source

pub fn chunk_metadata( &mut self, nums: &[T], spec: &ChunkSpec ) -> QCompressResult<ChunkMetadata<T>>

Writes out and returns chunk metadata after training the compressor. Will return an error if the compressor has not yet written the header, in the middle of a chunk, or if the spec provided is incompatible with the count of nums.

The spec indicates how the chunk’s data pages will be broken up; see ChunkSpec for more detail.

After this method, the compressor retains some precomputed information that only gets freed after every data page in the chunk has been written.

source

pub fn data_page(&mut self) -> QCompressResult<()>

Writes out a data page, using precomputed data passed in through .chunk_metadata. Will return an error if the compressor is not at the start of a data page in the middle of a chunk.

source

pub fn drain_bytes(&mut self) -> Vec<u8>

Returns all bytes produced by the compressor so far that have not yet been read.

source

pub fn byte_size(&mut self) -> usize

Returns the number of bytes produced by the compressor so far that have not yet been read.

Trait Implementations§

source§

impl<T: Clone + NumberLike> Clone for Compressor<T>

source§

fn clone(&self) -> Compressor<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug + NumberLike> Debug for Compressor<T>

source§

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

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

impl<T: NumberLike> Default for Compressor<T>

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Compressor<T>where <T as NumberLike>::Signed: RefUnwindSafe, <T as NumberLike>::Unsigned: RefUnwindSafe,

§

impl<T> Send for Compressor<T>where <T as NumberLike>::Signed: Send, <T as NumberLike>::Unsigned: Send,

§

impl<T> Sync for Compressor<T>where <T as NumberLike>::Signed: Sync, <T as NumberLike>::Unsigned: Sync,

§

impl<T> Unpin for Compressor<T>where <T as NumberLike>::Signed: Unpin, <T as NumberLike>::Unsigned: Unpin,

§

impl<T> UnwindSafe for Compressor<T>where <T as NumberLike>::Signed: UnwindSafe, <T as NumberLike>::Unsigned: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.