snappy-c: Bindings to Google's Snappy: A fast compression library

[ bsd3, codec, library, program ] [ Propose Tags ] [ Report a vulnerability ]

Snappy is a fast (de)compression library. It is written in C++, but a basic set of C bindings is also provided. Although the C bindings only support the "raw" Snappy format, this package provides support for the Snappy "frame" format on top of the raw C API, enabling extremely fast (de)compression of lazy (streamed) data.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.1
Change log CHANGELOG.md
Dependencies base (>=4.14 && <4.21), bytestring (>=0.10 && <0.13), conduit (>=1.3.5 && <1.4), data-default (>=0.7 && <0.8), digest (>=0.0.2 && <0.0.3), mtl (>=2.2.2 && <2.4), optparse-applicative (>=0.18 && <0.19), snappy-c [details]
Tested with ghc ==8.10.7, ghc ==9.2.8, ghc ==9.4.8, ghc ==9.6.4, ghc ==9.8.2
License BSD-3-Clause
Author Finley McIlwaine, Edsko de Vries
Maintainer finley@well-typed.com
Revised Revision 1 made by EdskoDeVries at 2024-05-29T12:46:20Z
Category Codec
Source repo head: git clone https://github.com/well-typed/snappy-c
Uploaded by EdskoDeVries at 2024-04-10T15:35:09Z
Distributions
Executables snappy-cli
Downloads 167 total (18 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user [build log]
All reported builds failed as of 2024-04-10 [all 2 reports]

Readme for snappy-c-0.1.1

[back to package description]

snappy-c

CI Status Badge

Haskell bindings to the C API of Snappy: A fast compression library.

Usage

[!IMPORTANT] To use this package, you must have the Snappy library installed and visible to cabal.

If your build fails with a message like:

Error: cabal-3.10.1.0: Missing dependency on a foreign library:
* Missing (or bad) C library: snappy

You need to explicitly configure the include and library paths via cabal. One way to do so is to add something like this to your cabal.project configuration:

package snappy-c
  extra-include-dirs:
    /path/to/snappy/include
  extra-lib-dirs:
    /path/to/snappy/lib

In my case, on a mac using homebrew, the following suffices:

package snappy-c
  extra-lib-dirs:
    /opt/homebrew/lib
  extra-include-dirs:
    /opt/homebrew/include

We wouldn't need to do this if the Snappy library supported pkg-config configuration, but as of writing they do not.

Installing Snappy

The Snappy library is available most package managers.

Homebrew

brew install snappy

APT

apt-get install libsnappy-dev

Performance

snappy-c stays true to the speedy spirit of Snappy compression.

The package includes a benchmark suite that compares the compression, decompression, and roundtrip performance of this package against

Run the benchmarks with:

cabal run bench-snappy-c -- --time-limit 5 -o bench.html

[!IMPORTANT] To build the benchmarks, you will need to set extra-include-dirs and extra-lib-dirs for the snappy package as you did for snappy-c (see Usage).

Here's a screenshot from the generated bench.html file:

benchmark results

snappy-cli performance

See snappy-cli/README.md for a demonstration of the performance of this library in a CLI tool.