Learn R Programming

mirai (version 2.6.0)

serial_config: Create Serialization Configuration

Description

Returns a serialization configuration, which may be set to perform custom serialization and unserialization of normally non-exportable reference objects, allowing these to be used seamlessly between different R sessions. Once set by passing to the serial argument of daemons(), the functions apply to all mirai requests for that compute profile.

Usage

serial_config(class, sfunc, ufunc)

Value

A list comprising the configuration. This should be passed to the serial argument of daemons().

Arguments

class

(character) class name(s) for custom serialization, e.g. 'ArrowTabular' or c('torch_tensor', 'ArrowTabular').

sfunc

(function | list) serialization function(s) accepting a reference object and returning a raw vector.

ufunc

(function | list) unserialization function(s) accepting a raw vector and returning a reference object.

Details

This feature utilises the 'refhook' system of R native serialization.

Examples

Run this code
cfg <- serial_config("test_cls", function(x) serialize(x, NULL), unserialize)
cfg

cfg2 <- serial_config(
  c("class_one", "class_two"),
  list(function(x) serialize(x, NULL), function(x) serialize(x, NULL)),
  list(unserialize, unserialize)
)
cfg2

Run the code above in your browser using DataLab