This module provides fast lossless compression for the Julia language by interfacing the Blosc Library.
Note that Blosc is currently limited to 32-bit buffer sizes. Blosc does run just fine on 64-bit systems; it just can't compress arrays bigger than 2GB. Note also that this limitation does not affect the use of Blosc compression for HDF5, since HDF5 breaks up large arrays into small chunks before compressing them. So, don't worry about this if you are just using Blosc within the HDF5 package.
To install, simply run Pkg.add("Blosc")
in Julia. Precompiled
binaries are provided for Mac and Windows systems, while on other
systems the Blosc library will be downloaded and compiled.
The functions provided are:
-
compress(src::Array{T}; level=5, shuffle=true, itemsize=sizeof(T))
: returns aVector{UInt8}
consisting ofsrc
in compressed form.level
is the compression level (between0
=no compression and9
=max),shuffle
indicates whether to use Blosc's shuffling preconditioner, which is optimized for arrays of binary items of sizeitemsize
. -
compress!(dest::Vector{UInt8}, src; ...)
: ascompress
, but uses a pre-allocated destination bufferdest
. Returns the size (in bytes) of the compressed data, or0
if the buffer was too small. -
decompress(T::Type, src::Vector{UInt8})
: return the compressed buffersrc
as an array of element typeT
. -
decompress!(dest::Vector{T}, src::Vector{UInt8})
: likedecompress
, but uses a pre-allocated destination buffer, which is resized as needed to store the decompressed data. -
Blosc.set_num_threads(n=CPU_CORES)
: tells Blosc to usen
threads (initially1
). -
Blosc.compressors()
: returns an array of strings for the available compression algorithms. (Theblosclz
compressor is the default.) -
Blosc.set_compressor(s::AbstractString)
: set the current compression algorithm
This module was written by Steven G. Johnson and Jake Bolewski (who had independently written his own Blosc.jl package which is now merged with this one).