All Projects → zraorg → ZRA

zraorg / ZRA

Licence: BSD-3-Clause license
ZStandard Random Access (ZRA) allows random access inside an archive compressed using ZStandard

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to ZRA

ratarmount
Random Access Read-Only Tar Mount
Stars: ✭ 217 (+933.33%)
Mutual labels:  compression, zstd, random-access, zstandard
Compress
Optimized Go Compression Packages
Stars: ✭ 2,478 (+11700%)
Mutual labels:  compression, zstd, zstandard
EasyCompressor
⚡ A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.
Stars: ✭ 167 (+695.24%)
Mutual labels:  compression, zstd, zstandard
box
Box - Open Standard Archive Format, a zip killer.
Stars: ✭ 38 (+80.95%)
Mutual labels:  compression, archive, zstandard
ZstdKit
An Objective-C and Swift library for Zstd (Zstandard) compression and decompression.
Stars: ✭ 22 (+4.76%)
Mutual labels:  compression, zstd, zstandard
pgzstd
Postgres module for Zstandard compression/decompression with preset dictionary support
Stars: ✭ 31 (+47.62%)
Mutual labels:  zstd, zstandard
zstd-rs
zstd-decoder in pure rust
Stars: ✭ 148 (+604.76%)
Mutual labels:  compression, zstd
pyrus-cramjam
Thin Python wrapper to de/compression algorithms in Rust - lightweight & no dependencies
Stars: ✭ 40 (+90.48%)
Mutual labels:  compression, zstd
Gozstd
go wrapper for zstd
Stars: ✭ 275 (+1209.52%)
Mutual labels:  compression, zstd
Libzip
A C library for reading, creating, and modifying zip archives.
Stars: ✭ 379 (+1704.76%)
Mutual labels:  compression, archive
Lizard
Lizard (formerly LZ5) is an efficient compressor with very fast decompression. It achieves compression ratio that is comparable to zip/zlib and zstd/brotli (at low and medium compression levels) at decompression speed of 1000 MB/s and faster.
Stars: ✭ 408 (+1842.86%)
Mutual labels:  compression, zstd
go7z
A native Go 7z archive reader.
Stars: ✭ 46 (+119.05%)
Mutual labels:  compression, archive
Zipper
🗳A library to create, read and modify ZIP archive files, written in Swift.
Stars: ✭ 38 (+80.95%)
Mutual labels:  compression, archive
Lzbench
lzbench is an in-memory benchmark of open-source LZ77/LZSS/LZMA compressors
Stars: ✭ 490 (+2233.33%)
Mutual labels:  compression, zstd
Junrar
Plain Java unrar library
Stars: ✭ 142 (+576.19%)
Mutual labels:  compression, archive
Zstdnet
Zstd wrapper for .NET
Stars: ✭ 176 (+738.1%)
Mutual labels:  compression, zstd
7 Zip Zstd
7-Zip with support for Brotli, Fast-LZMA2, Lizard, LZ4, LZ5 and Zstandard
Stars: ✭ 2,150 (+10138.1%)
Mutual labels:  zstd, zstandard
P7zip
A new p7zip fork with additional codecs and improvements (forked from https://sourceforge.net/projects/p7zip/).
Stars: ✭ 222 (+957.14%)
Mutual labels:  archive, zstd
Dwarfs
A fast high compression read-only file system
Stars: ✭ 444 (+2014.29%)
Mutual labels:  compression, zstd
Zstd Rs
A rust binding for the zstd compression library.
Stars: ✭ 159 (+657.14%)
Mutual labels:  compression, zstd

ZStandard Random Access (ZRA) allows random access inside an archive compressed using ZStandard
C/C++ CI


Format

How is this done?

ZSTD has the concept of a Frame which can be decompressed independently from the rest of the file. A ZSTD archive is made of multiple concatenated frames which are decompressed one after another.

We exploit that fact to break the file into uniformly sized frames (Frame Size) and creating a seek-table which contains the offset of each frame within in the file which can be indexed by simply dividing the offset by the frame size.

Header

We store data that's required for decompression or other functionality inside an archive header, that contains the following:

  • ZSTD Skippable Frame - The entire header is inside a ZSTD Skippable Frame so that ZRA is fully compatible with any regular ZSTD decompressor
  • CRC-32 Hash - A CRC-32 hash of the entire header to ensure integrity of the file is always preserved
  • Metadata Section - A section where data which might be used by a ZRA decompressor on the other side but not a part of the archive's contents itself
  • Seek-Table - A table with 40-bit entries containing the offset of individual frames

Usage

Compression

  • In-Memory
    zra::Buffer input = GetInput(); // A `zra::Buffer` full of data to be compressed
    zra::Buffer output = zra::CompressBuffer(input);
  • Streaming
    auto size = input.size();
    zra::Compressor compressor(size);
    output.seek(compressor.GetHeaderSize());
    
    zra::Buffer buffer; // The buffer is reused to prevent constant reallocation
    while (size) {
        auto readSize = std::min(maxChunkSize, size);
        compressor.Compress(input.read(readSize), buffer);
        output.write(buffer);
        size -= readSize;
    }
    
    output.seek(0);
    output.write(compressor.GetHeader());
    
    // Note: `input` and `output` in the example hold an internal offset that is automatically 
    // modified based on operations performed on them, similar to ifstream/ofstream from C++ 
    // Standard Library

Decompression (Entire File)

  • In-Memory
      zra::Buffer input = GetInput(); // A `zra::Buffer` with the entire archive
      zra::Buffer output = zra::DecompressBuffer(input);
  • Streaming
    zra::FullDecompressor decompressor([&input](size_t offset, size_t size, void* output) {
      input.seek(offset);
      input.read(output, size);
    });
    
    auto remaining = decompressor.header.uncompressedSize;
    zra::Buffer buffer(bufferSize); // The buffer is reused to prevent constant reallocation
    while (remaining) {
        auto amount = decompressor.Decompress(buffer);
        output.write(buffer, amount);
        remaining -= amount;
    }

Decompression (Random-Access)

  • In-Memory
    zra::Buffer input = GetInput();
    zra::Buffer output = zra::DecompressRA(input, offset, size);
  • Streaming
    zra::Decompressor decompressor([&input](size_t offset, size_t size, void* output) {
      input.seek(offset);
      input.read(output, size);
    });
    zra::Buffer output = decompressor.Decompress(offset, size);
    // or, to prevent buffer reallocation
    decompressor.Decompress(offset, size, output);

Retrieving Header

  • Using readFunction
    zra::Header header([&input](size_t offset, size_t size, void* output) {
      input.seek(offset);
      input.read(output, size);
    });
  • Using a pointer to the archive
    zra::Header header(input.data());
  • From Decompressor/FullDecompressor
    zra::Decompressor decompressor(...); // or zra::FullDecompressor
    decompressor.header;

License

We use a simple 3-clause BSD license located at LICENSE for easy integration into projects while being compatible with the libraries we utilize

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].