Module Zstandard
zstd, short for Zstandard, is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios. The zstd compression library provides in-memory compression and decompression functions. The library supports compression levels from 1 up to max_compression_level () (currently 22). Levels >= 20, labeled `--ultra`, should be used with caution, as they require more memory.
Compression can be done in:
- a single step (described as Simple API)
- a single step, reusing a context (described as Explicit context)
- unbounded multiple steps (described as Streaming compression)
The compression ratio achievable on small data can be highly improved using a dictionary in:
- a single step (described as Simple dictionary API)
- a single step, reusing a dictionary (described as Bulk-processing dictionary API)
Also see LZ4.
exceptionError of stringexceptionContent_size_unknownMight be raised when decompressing a message using a single pass decompression function.
Decompressed size is an optional field of compressed messages, but is always present when using a single-pass function such as
Simple.compress,With_explicit_content.comprss,Simple_dictionary.compressandWith_bulk_dictionary.compress. If the decompressed size is not present in the message, it might be necesary to use streaming mode to decompress the message.
exceptionContent_size_errorMight be raised when decompressing a message using a single pass decompression function, indicating an error when inspecting the message -- for instance, invalid magic numbers.
exceptionNot_enough_capacity of intCompression / decompression functions below might raise this exception if the return value they are passed does not have enough capacity. The argument is the required capacity.
exceptionDecompressed_size_exceeds_max_int of Core_kernel.Int64.tThe size of compressed messages is encoded in as a 64 bit integers. This OCaml library internally uses
Int.tto represent size and can't decode messages whose sizes would not fit on an int. For those messages, decompression using the streaming mode is recommended.
module Output : sig ... endmodule Input : sig ... endval decompressed_size : Input.t -> Core_kernel.Int64.tReturns the decompressed size of a message. Since decompressed size is an optional field of compressed message, it might raise
Content_size_unknown,Content_size_errororError.
module Compression_context : sig ... endmodule Decompression_context : sig ... endmodule Simple : sig ... endmodule With_explicit_context : sig ... endmodule Dictionary : sig ... endmodule Simple_dictionary : sig ... endmodule Bulk_processing_dictionary : sig ... endmodule Streaming : sig ... end