Skip to content

Write Arrow IPC data to a raw vector

Source code

Description

Write Arrow IPC data to a raw vector

Usage

<DataFrame>$to_raw_ipc(
  compression = c("uncompressed", "zstd", "lz4"),
  ...,
  compat_level = FALSE
)

Arguments

compression NULL or a character of the compression method, “uncompressed” or "lz4" or "zstd". NULL is equivalent to “uncompressed”. Choose "zstd" for good compression performance. Choose "lz4" for fast compression/decompression.
Ignored.
compat_level Use a specific compatibility level when exporting Polars’ internal data structures. This can be:
  • an integer indicating the compatibility version (currently only 0 for oldest and 1 for newest);
  • a logical value with TRUE for the newest version and FALSE for the oldest version.

Value

A raw vector

See Also

  • \$write_ipc()

Examples

library("polars")

df = pl$DataFrame(
  foo = 1:5,
  bar = 6:10,
  ham = letters[1:5]
)

raw_ipc = df$to_raw_ipc()

pl$read_ipc(raw_ipc)
#> shape: (5, 3)
#> ┌─────┬─────┬─────┐
#> │ foo ┆ bar ┆ ham │
#> │ --- ┆ --- ┆ --- │
#> │ i32 ┆ i32 ┆ str │
#> ╞═════╪═════╪═════╡
#> │ 1   ┆ 6   ┆ a   │
#> │ 2   ┆ 7   ┆ b   │
#> │ 3   ┆ 8   ┆ c   │
#> │ 4   ┆ 9   ┆ d   │
#> │ 5   ┆ 10  ┆ e   │
#> └─────┴─────┴─────┘
if (require("arrow", quietly = TRUE)) {
  arrow::read_ipc_file(raw_ipc, as_data_frame = FALSE)
}
#> Table
#> 5 rows x 3 columns
#> $foo <int32>
#> $bar <int32>
#> $ham <large_string>