Struct q_compress::wrapped::Decompressor
source · 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>
impl<T: NumberLike> Decompressor<T>
sourcepub fn from_config(config: DecompressorConfig) -> Self
pub fn from_config(config: DecompressorConfig) -> Self
Creates a new decompressor, given a DecompressorConfig
.
sourcepub fn header(&mut self) -> QCompressResult<Flags>
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.
sourcepub fn chunk_metadata(&mut self) -> QCompressResult<ChunkMetadata<T>>
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.
sourcepub fn begin_data_page(
&mut self,
n: usize,
compressed_page_size: usize
) -> QCompressResult<()>
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.
sourcepub fn next_batch(&mut self, limit: usize) -> QCompressResult<Vec<T>>
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.
sourcepub fn data_page(
&mut self,
n: usize,
compressed_page_size: usize
) -> QCompressResult<Vec<T>>
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)
.
sourcepub fn free_compressed_memory(&mut self)
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.
sourcepub fn clear_compressed_bytes(&mut self)
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.
Trait Implementations§
source§impl<T: Clone + NumberLike> Clone for Decompressor<T>
impl<T: Clone + NumberLike> Clone for Decompressor<T>
source§impl<T: Debug + NumberLike> Debug for Decompressor<T>
impl<T: Debug + NumberLike> Debug for Decompressor<T>
source§impl<T: Default + NumberLike> Default for Decompressor<T>
impl<T: Default + NumberLike> Default for Decompressor<T>
source§impl<T: NumberLike> Write for Decompressor<T>
impl<T: NumberLike> Write for Decompressor<T>
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)