Function blosc_src::blosc_compress [−][src]
pub unsafe extern "C" fn blosc_compress(
clevel: c_int,
doshuffle: c_int,
typesize: usize,
nbytes: usize,
src: *const c_void,
dest: *mut c_void,
destsize: usize
) -> c_int
Expand description
Compress a block of data in the src
buffer and returns the size of
the compressed block. The size of src
buffer is specified by
nbytes
. There is not a minimum for src
buffer size (nbytes
).
clevel
is the desired compression level and must be a number
between 0 (no compression) and 9 (maximum compression).
doshuffle
specifies whether the shuffle compression filters
should be applied or not. BLOSC_NOSHUFFLE means not applying it,
BLOSC_SHUFFLE means applying it at a byte level and BLOSC_BITSHUFFLE
at a bit level (slower but may achieve better entropy alignment).
typesize
is the number of bytes for the atomic type in binary
src
buffer. This is mainly useful for the shuffle filters.
For implementation reasons, only a 1 < typesize
< 256 will allow the
shuffle filter to work. When typesize
is not in this range, shuffle
will be silently disabled.
The dest
buffer must have at least the size of destsize
. Blosc
guarantees that if you set destsize
to, at least,
(nbytes
+ BLOSC_MAX_OVERHEAD), the compression will always succeed.
The src
buffer and the dest
buffer can not overlap.
Compression is memory safe and guaranteed not to write the dest
buffer beyond what is specified in destsize
.
If src
buffer cannot be compressed into destsize
, the return
value is zero and you should discard the contents of the dest
buffer.
A negative return value means that an internal error happened. This should never happen. If you see this, please report it back together with the buffer data causing this and compression settings.
Environment variables
blosc_compress() honors different environment variables to control internal parameters without the need of doing that programatically. Here are the ones supported:
BLOSC_CLEVEL=(INTEGER): This will overwrite the clevel
parameter
before the compression process starts.
BLOSC_SHUFFLE=[NOSHUFFLE | SHUFFLE | BITSHUFFLE]: This will
overwrite the doshuffle
parameter before the compression process
starts.
BLOSC_TYPESIZE=(INTEGER): This will overwrite the typesize
parameter before the compression process starts.
BLOSC_COMPRESSOR=[BLOSCLZ | LZ4 | LZ4HC | SNAPPY | ZLIB]: This will call blosc_set_compressor(BLOSC_COMPRESSOR) before the compression process starts.
BLOSC_NTHREADS=(INTEGER): This will call blosc_set_nthreads(BLOSC_NTHREADS) before the compression process starts.
BLOSC_BLOCKSIZE=(INTEGER): This will call blosc_set_blocksize(BLOSC_BLOCKSIZE) before the compression process starts. NOTE: The blocksize is a critical parameter with important restrictions in the allowed values, so use this with care.
BLOSC_NOLOCK=(ANY VALUE): This will call blosc_compress_ctx() under
the hood, with the compressor
, blocksize
and
numinternalthreads
parameters set to the same as the last calls to
blosc_set_compressor(), blosc_set_blocksize() and
blosc_set_nthreads(). BLOSC_CLEVEL, BLOSC_SHUFFLE, BLOSC_TYPESIZE
environment vars will also be honored.
BLOSC_SPLITMODE=[ FORWARD_COMPAT | AUTO | ALWAYS | NEVER ]: This will call blosc_set_splitmode() with the different supported values. See blosc_set_splitmode() docstrings for more info on each mode.
BLOSC_WARN=(INTEGER): This will print some warning message on stderr showing more info in situations where data inputs cannot be compressed. The values can range from 1 (less verbose) to 10 (full verbose). 0 is the same as if the BLOSC_WARN envvar was not defined.