Skip to content

Commit

Permalink
version 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thekvs authored and cran-robot committed Jun 2, 2017
0 parents commit 7a2e291
Show file tree
Hide file tree
Showing 298 changed files with 119,897 additions and 0 deletions.
29 changes: 29 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Package: zstdr
Type: Package
Title: R Bindings to Zstandard Compression Library
Version: 0.1.0
Authors@R: c(
person("Konstantin", "Sorokin", email = "kvs@sigterm.ru", role = c("aut", "cre")),
person("Facebook, Inc", role = c("aut","cph"), comment = "Fast real-time compression library")
)
Maintainer: Konstantin Sorokin <kvs@sigterm.ru>
Description: Provides R bindings to the 'Zstandard' compression library.
'Zstandard' is a real-time compression algorithm, providing high compression ratios.
It offers a very wide range of compression / speed trade-off, while being backed by a very fast decoder.
See <http://facebook.github.io/zstd/> for more information.
URL: https://github.com/thekvs/zstdr
BugReports: https://github.com/thekvs/zstdr/issues
License: GPL (>= 2)
LazyData: TRUE
SystemRequirements: C++11
Imports: Rcpp (>= 0.12.0)
LinkingTo: Rcpp
RoxygenNote: 6.0.1
Suggests: testthat
OS_type: unix
NeedsCompilation: yes
Packaged: 2017-06-02 09:23:12 UTC; kvs
Author: Konstantin Sorokin [aut, cre],
Facebook, Inc [aut, cph] (Fast real-time compression library)
Repository: CRAN
Date/Publication: 2017-06-02 17:58:31 UTC
297 changes: 297 additions & 0 deletions MD5

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
useDynLib(zstdr)
export(
zstdCompress,
zstdDecompress,
zstdMaxCLevel
)
importFrom(Rcpp, evalCpp)
15 changes: 15 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

zstdCompressImpl <- function(data, level) {
.Call('zstdr_zstdCompressImpl', PACKAGE = 'zstdr', data, level)
}

zstdDecompressImpl <- function(data) {
.Call('zstdr_zstdDecompressImpl', PACKAGE = 'zstdr', data)
}

zstdMaxCLevelImpl <- function() {
.Call('zstdr_zstdMaxCLevelImpl', PACKAGE = 'zstdr')
}

64 changes: 64 additions & 0 deletions R/zstd.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#' Zstandard comression
#'
#' Zstandard, or zstd as short version, is a fast lossless compression algorithm, targeting real-time compression scenarios
#' at zlib-level and better compression ratios.
#'
#' Compresses data using zstandard algorithm
#'
#' @export
#' @seealso \link{memCompress} \link{zstdDecompress} \link{zstdMaxCLevel}
#' @references \url{http://facebook.github.io/zstd/}
#' @param data input data to be compressed or decomressed
#' @param level compression level to use, value between 1 and returned by \link{zstdMaxCLevel} function, default is 3
#' @return compressed data
#' @examples # Simple example
#' library(zstdr)
#' data_file <- file.path(R.home(), "COPYING")
#' data <- readBin(data_file, raw(), file.info(data_file)$size)
#' compressed <- zstdCompress(data)
#' stopifnot(identical(data, zstdDecompress(compressed)))
zstdCompress <- function(data, level=3) {
stopifnot(is.numeric(level))

if (is.character(data)) {
return(zstdCompressImpl(charToRaw(data), as.integer(level)))
} else if (is.raw(data)) {
return(zstdCompressImpl(data, as.integer(level)))
} else {
stop("data must be of raw or character type")
}
}

#' Zstandard comression
#'
#' Zstandard, or zstd as short version, is a fast lossless compression algorithm, targeting real-time compression scenarios
#' at zlib-level and better compression ratios.
#'
#' Decompresses data previously compressed with \link{zstdCompress}
#'
#' @export
#' @seealso \link{memCompress} \link{zstdCompress} \link{zstdMaxCLevel}
#' @param data input data to be decomressed
#' @return decompressed data
#' @examples # Simple example
#' library(zstdr)
#' data_file <- file.path(R.home(), "COPYING")
#' data <- readBin(data_file, raw(), file.info(data_file)$size)
#' compressed <- zstdCompress(data)
#' stopifnot(identical(data, zstdDecompress(compressed)))
zstdDecompress <- function(data) {
if (!is.raw(data)) {
stop("input data must be raw")
}

return(zstdDecompressImpl(data))
}

#' Returns maximum compression level supported by zstandard
#'
#' @export
#' @seealso \link{memCompress} \link{zstdCompress} \link{zstdDecompress}
#' @return maximum supported compression level
zstdMaxCLevel <- function() {
return(zstdMaxCLevelImpl())
}
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

[![Build Status](https://travis-ci.org/thekvs/zstdr.svg?branch=master)](https://travis-ci.org/thekvs/zstdr)

About
-----

This package provides simple R bindings to the [Zstandard compression library](http://facebook.github.io/zstd/).

Benchmarks
----------

See [benchmarks](Benchmarks.md) for comparison with other compression algorithms.

Installation
------------

For the moment you can only install from GitHub:

``` r
devtools::install_github("thekvs/zstdr")
```

Usage
-----

``` r
library(zstdr)

data_file <- file.path(R.home(), "COPYING")
data <- readBin(data_file, raw(), file.info(data_file)$size)
compressed <- zstdCompress(data)
stopifnot(identical(data, zstdDecompress(compressed)))
```

Links
-----

- [zstandard official site](http://facebook.github.io/zstd/)
- [zstandard C API documentation](http://facebook.github.io/zstd/zstd_manual.html)
5 changes: 5 additions & 0 deletions cleanup
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

rm -rf autom4te.cache/ config.log config.status \
src/Makevars src/*.o src/*.so src/*.dylib \
src/third_party/build src/third_party/install *~

0 comments on commit 7a2e291

Please sign in to comment.