libdeflate

Static Library and Headers for 'DEFLATE' Compression

https://github.com/tylermorganwall/libdeflate

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.1%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

Static Library and Headers for 'DEFLATE' Compression

Basic Info
  • Host: GitHub
  • Owner: tylermorganwall
  • License: other
  • Language: C
  • Default Branch: main
  • Size: 271 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • Open Issues: 1
  • Releases: 0
Created about 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License

README.Rmd

# libdeflate


[![R-CMD-check](https://github.com/tylermorganwall/libdeflate/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tylermorganwall/libdeflate/actions/workflows/R-CMD-check.yaml)


High‑performance DEFLATE compression for R, wrapping Eric Biggers’ [`libdeflate`](https://github.com/ebiggers/libdeflate) C library.

The installed package includes a **static** copy of the C library (along with CMake config files) so you can use DEFLATE compression in your package without requiring the user to separately install libdeflate as a system dependency. The package also includes a minimal R API that allows for compression and decompression of raw vectors, which can serve as an implementation reference for any downstream libraries.

---

## Installation

```r
# once released on CRAN
install.packages("libdeflate")

# development version
remotes::install_github("tylermorganwall/libdeflate")
```

No external libraries are required—the libdeflate static library is built and installed during the R package install.

---

## Example

```{r}
library(libdeflate)

raw_in  = charToRaw("Example data payload, 123412341234123412341234")

print(raw_in)
length(raw_in)

cmp     = alloc_compressor(level = 6L)      # create compressor @ default level
raw_cmp = deflate_compress(cmp, raw_in)     # compress

print(raw_cmp)
length(raw_cmp)

dcmp    = alloc_decompressor()              # create decompressor
raw_out = deflate_decompress(dcmp, raw_cmp, length(raw_in))

print(raw_out)
print(rawToChar(raw_out)) # round‑trip successful
```

---

## R API

| Function | Purpose | Key arguments |
|----------|---------|---------------|
| `alloc_compressor(level = 6L)` | Allocate a compression context. | `level` ∈ **0…12** *(0 = none, 6 = default, 12 = max)* |
| `deflate_compress(compressor, input)` | Compress a `raw` vector. | `compressor`, `input` *(coerced to raw)* |
| `alloc_decompressor()` | Allocate a decompression context. | – |
| `deflate_decompress(decompressor, input, out_len)` | Inflate a DEFLATE stream. | `decompressor`, `input`, `out_len` *(expected size)* |

All four functions are simple `.Call()` wrappers around the C API; see the `@examples` in their help pages for typical workflows.

---

## Using the bundled static library in your own packages

The package installs

```
lib//libdeflate.a        # static archive
lib//cmake/libdeflate/*  # CMake config files
include/libdeflate.h             # public header
```

`R_ARCH` can be obtained in R via `Sys.info()[["machine"]]`.

### Makevars‑style linkage

```make
## configure
DEFLATE_DIR=$(Rscript -e 'cat(system.file("lib", Sys.info()[["machine"]], package = "libdeflate"))')
CPPFLAGS += -I$(DEFLATE_DIR)/../include
PKG_LIBS += -L$(DEFLATE_DIR) -ldeflate
```

### CMake consumers

Call this R code in your configure step to determine the location of the CMake config files:

```r
DEFLATE_LIB_ARCH = normalizePath(sprintf(
  "%s/%s",
  system.file(
    "lib",
    package = "libdeflate",
    mustWork = TRUE
  ),
  Sys.info()[["machine"]]
))

DEFLATE_CMAKE_CONFIG = file.path(DEFLATE_LIB_ARCH, "cmake", "libdeflate")
```

---

## Minimal C wrapper (see r-api.c in package source)

```c
// File: src/r-api.c
#define R_NO_REMAP
#include 
#include 
#include 

SEXP C_alloc_compressor(SEXP level_SEXP) {
    int level = INTEGER(level_SEXP)[0];
    struct libdeflate_compressor *c = libdeflate_alloc_compressor(level);
    if(!c) Rf_error("libdeflate_alloc_compressor(%d) failed", level);
    SEXP ext = PROTECT(R_MakeExternalPtr(c, R_NilValue, R_NilValue));
    R_RegisterCFinalizerEx(ext, compressor_finalizer, TRUE);
    UNPROTECT(1);
    return ext;
}

```

Owner

  • Login: tylermorganwall
  • Kind: user

GitHub Events

Total
  • Issues event: 1
  • Push event: 36
  • Public event: 1
  • Create event: 1
Last Year
  • Issues event: 1
  • Push event: 36
  • Public event: 1
  • Create event: 1

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 52
  • Total Committers: 1
  • Avg Commits per committer: 52.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 52
  • Committers: 1
  • Avg Commits per committer: 52.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
tylermorganwall t****l 52

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 1
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • barracuda156 (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 381 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 7
  • Total maintainers: 1
cran.r-project.org: libdeflate

DEFLATE Compression and Static Library

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 381 Last month
Rankings
Dependent packages count: 26.6%
Dependent repos count: 32.8%
Average: 48.7%
Downloads: 86.6%
Maintainers (1)
Last synced: 11 months ago

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v4 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/rhub.yaml actions
  • r-hub/actions/checkout v1 composite
  • r-hub/actions/platform-info v1 composite
  • r-hub/actions/run-check v1 composite
  • r-hub/actions/setup v1 composite
  • r-hub/actions/setup-deps v1 composite
  • r-hub/actions/setup-r v1 composite
DESCRIPTION cran
  • R >= 3.5.0 depends