This package providesR withboth theMessagePack (or MsgPack as ashorthand) header files, and the ability to access, create and alterMessagePack objects directly fromR.
MessagePack is an efficient binaryserialization format. It lets you exchange data among multiple languageslike JSON. But it is faster and smaller. Small integers are encoded intoa single byte, and typical short strings require only one extra byte inaddition to the strings themselves.MessagePack is used by Redis and manyother projects.
TheR Journalpaper describes both theRcppMsgPack package andMessagePack.
To use the headers from this package, simply add it to theLinkingTo: field in theDESCRIPTION field ofyour R package—and the R package infrastructure tools will then know howto set include flags correctly on all architectures supported by R.
The functionsmsgpack_pack andmsgpack_unpack allow you to serialize and de-serialize Robjects respectively.msgpack_format is a helper functionto properly format R objects for input.msgpack_simplify isa helper function to simplify output from MsgPack conversion.
MsgPack EXT types are converted to raw vectors with EXT attributescontaining the extension type. The extension type must be an integerfrom 0 to 127. MsgPack Timestamps are an EXT with type -1. Timestampscan be encoded and decoded fromPOSIXct objects in R toMsgPack format withmsgpack_timestamp_encode andmsgpack_timestamp_decode.
Msgpack Maps are converted to data.frames with additional class“map”. Map objects in R contain key and value list columns and can besimplified to named lists or named vectors. The helper functionmsgpack_map creates map objects that can be serialized intomsgpack.
A flowchart describing the conversion of Robjects into msgpack objects and back.
For more information on msgpack types, seehere.
x <- as.list(1:1e6)x_packed <- msgpack_pack(x)x_unpacked <- msgpack_unpack(x_packed)The package is onCRAN andcan be installed via a standard
install.packages("RcppMsgPack")Pre-releases have been available via theghrr drat repository:
drat::addRepo("ghrr")install.packages("RcppMsgPack")The package currently includes the MessagePack headers version2.1.5.
See theBHpackage for related (and also header-only) libraries fromBoost, and theRcppRedispackage for simple yet performant Redis support.
Theissuetracker can be used for bug reports or feature requests.
Dirk Eddelbuettel andTraversChing.
Special thanks toXun Zhu.
The R package is provided under the GPL (version 2 or later). Theincluded MsgPack library is released under the same license as Boost,the BSL-1.0.
Initially created: Mon Jun 12 21:15:17 CDT 2017
Last modified: Sun May 26 10:18:34 CDT 2024