Skip to content

Serialize the logical plan of this LazyFrame

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 01 00 00 00 81 ab 4d 61 70 46 75 6e 63 74
#>  [26] 69 6f 6e 82 a5 69 6e 70 75 74 81 ad 44 61 74 61 46 72 61 6d 65 53 63 61 6e
#>  [51] 82 a2 64 66 c5 01 98 ff ff ff ff b8 00 00 00 04 00 00 00 f2 ff ff ff 14 00
#>  [76] 00 00 04 00 01 00 00 00 0a 00 0b 00 08 00 0a 00 04 00 f2 ff ff ff 48 00 00
#> [101] 00 10 00 00 00 00 00 0a 00 0c 00 00 00 04 00 08 00 01 00 00 00 04 00 00 00
#> [126] f4 ff ff ff 18 00 00 00 0c 00 00 00 08 00 0c 00 04 00 08 00 03 00 00 00 5b
#> [151] 30 5d 00 09 00 00 00 5f 50 4c 5f 46 4c 41 47 53 00 00 00 01 00 00 00 04 00
#> [176] 00 00 ec ff ff ff 38 00 00 00 20 00 00 00 18 00 00 00 01 02 00 00 10 00 12
#> [201] 00 04 00 10 00 11 00 08 00 00 00 0c 00 00 00 00 00 f4 ff ff ff 20 00 00 00
#> [226] 01 00 00 00 08 00 09 00 04 00 08 00 01 00 00 00 61 00 00 00 00 00 00 00 ff
#> [251] ff ff ff 88 00 00 00 04 00 00 00 ec ff ff ff 40 00 00 00 00 00 00 00 14 00
#> [276] 00 00 04 00 03 00 0c 00 13 00 10 00 12 00 0c 00 04 00 e6 ff ff ff 03 00 00
#> [301] 00 00 00 00 00 40 00 00 00 14 00 00 00 00 00 00 00 00 00 0a 00 14 00 04 00
#> [326] 0c 00 10 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
#> [351] 00 00 00 00 00 00 00 0c 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 03 00
#> [376] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 02 00 00
#> [401] 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
#> [426] 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
#> [451] 00 00 00 00 00 00 00 ff ff ff ff 00 00 00 00 a6 73 63 68 65 6d 61 81 a6 66
#> [476] 69 65 6c 64 73 81 a1 61 a5 49 6e 74 33 32 a8 66 75 6e 63 74 69 6f 6e 81 a5
#> [501] 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   │
#> └─────┘