Rhpc_serialize: Serialize and unserialize R objects

View source: R/RhpcSerialzie.R

Rhpc_serializeR Documentation

Serialize and unserialize R objects

Description

Serialize R objects for transmission or storage, and unserialize them back.

Usage

Rhpc_serialize(obj)
Rhpc_serialize_onlysize(obj)
Rhpc_serialize_norealloc(obj)
Rhpc_unserialize(obj)

Arguments

obj

R object to serialize, or serialized object to unserialize

Details

These functions provide low-level serialization utilities for handling R objects:

Rhpc_serialize

Fully serializes an object to raw bytes, allocating necessary memory

Rhpc_serialize_onlysize

Returns only the size needed for serialization without actual serialization

Rhpc_serialize_norealloc

Serializes without reallocating memory (for efficiency)

Rhpc_unserialize

Reconstructs an R object from its serialized form

These functions are primarily intended for internal Rhpc use but may be useful for debugging or advanced users.

Value

For Rhpc_serialize: raw vector containing serialized data

For Rhpc_serialize_onlysize: integer giving the size in bytes

For Rhpc_serialize_norealloc: raw vector containing serialized data

For Rhpc_unserialize: original R object

Examples

## Serialization example (executable without MPI)
data_to_serialize <- list(a = 1:5, b = c("x", "y", "z"))
serialized <- Rhpc_serialize(data_to_serialize)
deserialized <- Rhpc_unserialize(serialized)
stopifnot(identical(data_to_serialize, deserialized))

Rhpc documentation built on Aug. 4, 2026, 1:07 a.m.