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

Converts wrapped Quantile-compressed data into Flags, ChunkMetadata, and vectors of numbers.

All decompressor methods leave its state unchanged if they return an error.

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

Implementations§

source§

impl<T: NumberLike> Decompressor<T>

source

pub fn from_config(config: DecompressorConfig) -> Self

Creates a new decompressor, given a DecompressorConfig.

source

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

Reads the header, returning its Flags and updating this decompressor’s state. Will return an error if the decompressor has already parsed a header, is not byte-aligned, runs out of data, finds flags from a newer, incompatible version of q_compress, or finds any corruptions.

source

pub fn chunk_metadata(&mut self) -> QCompressResult<ChunkMetadata<T>>

Reads the chunk metadata, returning its metadata and updating the decompressor’s state. Will return an error if the decompressor has not parsed the header, runs out of data, or finds any corruptions.

This can be used regardless of whether the decompressor has finished reading all data pages from the preceding chunk.

source

pub fn begin_data_page( &mut self, n: usize, compressed_page_size: usize ) -> QCompressResult<()>

Initializes the decompressor for the next data page, reading in the data page’s metadata but not the compressed body. Will return an error if the decompressor is not in a chunk, runs out of data, or finds any corruptions.

This can be used regardless of whether the decompressor has finished reading the previous data page.

source

pub fn next_batch(&mut self, limit: usize) -> QCompressResult<Vec<T>>

Reads up to limit numbers from the current data page. Will return an error if the decompressor is not in a data page, it runs out of data, or any corruptions are found.

source

pub fn data_page( &mut self, n: usize, compressed_page_size: usize ) -> QCompressResult<Vec<T>>

Reads an entire data page, returning its numbers. Will return an error if the decompressor is not in a chunk, it runs out of data, or any corruptions are found.

This is similar to calling .begin_data_page and then .next_batch(usize::MAX).

source

pub fn free_compressed_memory(&mut self)

Frees memory used for storing compressed bytes the decompressor has already decoded. Note that calling this too frequently can cause performance issues.

source

pub fn clear_compressed_bytes(&mut self)

Clears any data written to the decompressor but not yet decompressed. As an example, if you want to want to read the first 5 numbers from each data page, you might write each compressed data page to the decompressor, then repeatedly call .begin_data_page, .next_nums, and this method.

source

pub fn bit_idx(&self) -> usize

Returns the current bit position into the compressed data the decompressor is pointed at. Note that when memory is freed, this will decrease.

Trait Implementations§

source§

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

source§

fn clone(&self) -> Decompressor<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 Decompressor<T>

source§

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

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

impl<T: Default + NumberLike> Default for Decompressor<T>

source§

fn default() -> Decompressor<T>

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

impl<T: NumberLike> Write for Decompressor<T>

source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Write a buffer into this writer, returning how many bytes were written. Read more
source§

fn flush(&mut self) -> Result<()>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Decompressor<T>where T: UnwindSafe, <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.