Convert to and from msgpack objects in R using the official msgpack-c API through Rcpp.
A flowchart describing the conversion of R objects into msgpack objects and back.
Msgpack EXT types are converted to raw vectors with EXT attributes containing the extension type. The extension type must be an integer from 0 to 127.
Maps are converted to data.frames with additional class “map”. Map
objects in R contain key and value list columns and can be simplified to
named lists or named vectors. The helper function
msgpack_map
creates map objects that can be serialized into
msgpack.
For more information on msgpack types, see here.
Install.packages("RcppMsgPack")
See tests/tests.r
for more examples.
library(RcppMsgPack)
library(microbenchmark)
x <- 1:1e6
microbenchmark(xpk <- msgpack_pack(x), times=3)
## Unit: milliseconds
## expr min lq mean median uq max
## xpk <- msgpack_pack(x) 18.03492 18.68427 19.70162 19.33362 20.53498 21.73633
## neval
## 3
## Unit: milliseconds
## expr min lq mean median uq
## xu <- msgpack_unpack(xpk) 58.91118 91.74375 129.0765 124.5763 164.1592
## max neval
## 203.7421 3