Learn R Programming

mirai (version 1.2.0)

serialization: Custom Serialization Functions

Description

[Deprecated in favour of the '.serial' argument to everywhere] Registers custom serialization and unserialization functions for sending and receiving reference objects. Settings apply to an individual compute profile, and daemons must have been set beforehand.

Usage

serialization(fns, class, vec = FALSE)

Value

Invisibly, a list comprising the currently-registered serialization configuration for the ‘default’ compute profile (an empty list if not registered).

Arguments

fns

either a list comprising 2 functions:
serialization function: must accept a reference object (or list of objects) inheriting from ‘class’ and return a raw vector.
unserialization function: must accept a raw vector and return a reference object (or list of reference objects).
or else NULL to reset.

class

the class of reference object (as a character string) that these functions are applied to, e.g. 'ArrowTabular' or 'torch_tensor'

vec

[default FALSE] whether or not the serialization functions are vectorized and accept and return a list of reference objects, e.g. torch::torch_serialize and torch::torch_load, or if FALSE return reference objects individually e.g. arrow::write_to_raw and arrow::read_ipc_stream.

Details

Registering new functions replaces any existing registered functions.

Examples

Run this code
daemons(url = local_url())

reg <- serialization(
  fns = list(function(x) serialize(x, NULL), unserialize),
  class = "custom_class"
)
reg

reg <- serialization(NULL)
reg

daemons(0)

Run the code above in your browser using DataLab