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"),
  ...,
  future = 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.
future Setting this to TRUE will write Polars’ internal data structures that might not be available by other Arrow implementations. This functionality is considered unstable. It may be changed at any point without it being considered a breaking change.

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>