C Library for Powerful and Fast Compression
Zstandard is an open source C compression library that provides a powerful and fast algorithm for high compression ratios inside C applications. The library offers a wide range of speed and is available under dual BSD and GPLv2 licensed. The library supports dictionary compression mode which is useful for small data compression.
The Zstandard library target real-time compression scenarios at zlib-level and better compression ratios. The library supports regular compression levels from 1 up 22. Please remember that Levels 20 and higher must be used with care, as much more memory is required for smooth working.
The API is stable, well documented, and easy to handle. It supports several important functions related to compression and decompression, streaming compression as well as decompression, dictionary helper functions, frame sizing, better memory management. The library also supports advanced functions for compression and decompression, Buffer-less and synchronous inner streaming functions, buffer-less streaming compression, and decompression (synchronous mode).
At A Glance
An overview of zip features.
- Compress Data
- Decompress Data
- Multi-threaded Compression
- Small Data Compression
- Modify ZIP-archives
- Append File
- Extract Specific Entry
Zstandard only requires Go runtime for smooth running.
Getting Started with Zstandard
The recommended way to install Zstandard is from GitHub. Use the following command for smooth installation.
Install Zstandard Library via GitHub
gh repo clone facebook/zstd
Compression and Decompression via C API
The open source library Zstandard has included several important functions for compression and decompression. The library offers in-memory compression and decompression functions. It offers several compression levels that extend the speed and ratio preferences. You can easily compress or decompress a single file as well as multiple files in a single command. With the new release, the decompression speed has been further improved.
Multi-threaded Compression & Decompression via C API
There are several compression libraries that are single-threaded which means users need to trust another piece of software or writing your own multi-threaded code. The open source library Zstandard has included features that allow a compression operation to leverage multiple threads using C commands. The great thing is that the compression process can switch to multi-threaded API and the decompression process won’t require any special handling.
Small Data Compression and Decompression
Usually, it has been seen that it is always difficult to compress or decompress a smaller amount of data. It is a common problem faced by most compression programs. The Zstandard library has improved this by offering a training mode which allows users to choose a selected type of data. Thus few samples are used with a small amount of data in the training module to tune the program. The result of the training module is stored in a file called the dictionary, which is used in the future before any compression and decompression. It has been observed that the compression algorithm learns from the past data that how to compress future data. Thus using the dictionary concept the compression and decompression ratio on small data has been greatly improved.