snappier | R Documentation |
Snappy is a fast compression library written by google and widely used in distributed systems.
This package provides bindings to the standard snappy implementation.
compress(chars) compress_raw(raw) decompress(raw) decompress_raw(raw)
chars |
A character vector (of length 1) to compress with snappy. |
raw |
A raw vector (RAWSXP) to compress or decompress with snappy. |
These binding contain the snappy C++ code and necessary R wrappers, so there is no need to install or link to a snappy dynamic library (so or dll file) in order to use this package.
Furthermore, these binding work at the level or raw bytes, not
character vectors, which is more robust and should be faster.
Use compress_raw
and decompress_raw
when working
with anything other than text.
compress
and decompress
provide wrappers
around compress_raw
and decompress_raw
which convert R character vectors into the raw
type needed by the underlying engine.
compress
returns the raw snappy encoded bytes of
the text input.
compress_raw
returns the raw snappy encoded bytes
of the raw input.
decompress
returns the a character vector made
from the decoded bytes of its input. If this coercion
can't be performed (i.e., the bytes can't be represented
as a string) an error will be thrown.
decompress_raw
returns the a raw bytes decoded from
its input. When passed bytes which are not snappy
compressed, this function will return NULL.
library(snappier) # Roundtrip compression of character vector decompress( compress( "this and that" ) ) # "this and that" compress("") # 00 compress_raw(c()) # 00 decompress_raw(0) # raw(0) decompress(0) # ""
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.