Skip to content

Serialize the logical plan of this LazyFrame

Source code

Description

Serialize the logical plan of this LazyFrame

Usage

<LazyFrame>$serialize(..., format = c("binary", "json"))

pl__deserialize_lf(data)

Arguments

These dots are for future extensions and must be empty.
format A character of the format in which to serialize. One of:
  • “binary” (default): Serialize to binary format (raw vector).
  • “json”: [Deprecated] Serialize to JSON format (character vector).
data A raw vector of serialized LazyFrame.

Value

  • \$serialize() returns raw or character, depending on the format argument.
  • pl$deserialize_lf() returns a deserialized LazyFrame.

Examples

library("polars")

lf <- pl$LazyFrame(a = 1:3)$sum()

# Serialize the logical plan to a binary representation.
serialized <- lf$serialize()
serialized
#>   [1] 44 53 4c 5f 56 45 52 53 49 4f 4e 16 00 00 00 37 32 65 34 38 37 36 30 35 35
#>  [26] 35 62 36 32 34 38 61 36 66 37 65 63 34 62 30 38 37 65 65 38 66 35 36 63 63
#>  [51] 38 38 64 64 32 63 30 38 61 30 34 64 31 64 33 37 36 30 38 33 30 31 38 35 32
#>  [76] 65 63 61 64 81 ab 4d 61 70 46 75 6e 63 74 69 6f 6e 82 a5 69 6e 70 75 74 81
#> [101] ad 44 61 74 61 46 72 61 6d 65 53 63 61 6e 82 a2 64 66 c5 01 90 ff ff ff ff
#> [126] b8 00 00 00 04 00 00 00 f2 ff ff ff 14 00 00 00 04 00 01 00 00 00 0a 00 0b
#> [151] 00 08 00 0a 00 04 00 f2 ff ff ff 48 00 00 00 10 00 00 00 00 00 0a 00 0c 00
#> [176] 00 00 04 00 08 00 01 00 00 00 04 00 00 00 f4 ff ff ff 18 00 00 00 0c 00 00
#> [201] 00 08 00 0c 00 04 00 08 00 03 00 00 00 5b 30 5d 00 09 00 00 00 5f 50 4c 5f
#> [226] 46 4c 41 47 53 00 00 00 01 00 00 00 04 00 00 00 ec ff ff ff 38 00 00 00 20
#> [251] 00 00 00 18 00 00 00 01 02 00 00 10 00 12 00 04 00 10 00 11 00 08 00 00 00
#> [276] 0c 00 00 00 00 00 f4 ff ff ff 20 00 00 00 01 00 00 00 08 00 09 00 04 00 08
#> [301] 00 01 00 00 00 61 00 00 00 00 00 00 00 ff ff ff ff 80 00 00 00 04 00 00 00
#> [326] ec ff ff ff 40 00 00 00 00 00 00 00 14 00 00 00 04 00 03 00 0c 00 13 00 10
#> [351] 00 12 00 0c 00 04 00 ea ff ff ff 03 00 00 00 00 00 00 00 3c 00 00 00 10 00
#> [376] 00 00 00 00 0a 00 14 00 04 00 0c 00 10 00 02 00 00 00 00 00 00 00 00 00 00
#> [401] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c 00 00 00 00 00 00 00
#> [426] 00 00 00 00 01 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
#> [451] 00 00 00 02 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
#> [476] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
#> [501] 00 00 00 00 00 00 00 00 00 00 00 00 00 ff ff ff ff 00 00 00 00 a6 73 63 68
#> [526] 65 6d 61 81 a6 66 69 65 6c 64 73 81 a1 61 a5 49 6e 74 33 32 a8 66 75 6e 63
#> [551] 74 69 6f 6e 81 a5 53 74 61 74 73 a3 53 75 6d
# The bytes can later be deserialized back into a LazyFrame.
pl$deserialize_lf(serialized)$collect()
#> shape: (1, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ i32 │
#> ╞═════╡
#> │ 6   │
#> └─────┘