record_batch()
函数用于从一个或多个列构造 RecordBatch,而 as_record_batch()
函数则用于将单个对象转换为 Arrow RecordBatch。
用法
as_record_batch(x, ..., schema = NULL)
# S3 method for class 'RecordBatch'
as_record_batch(x, ..., schema = NULL)
# S3 method for class 'Table'
as_record_batch(x, ..., schema = NULL)
# S3 method for class 'arrow_dplyr_query'
as_record_batch(x, ...)
# S3 method for class 'data.frame'
as_record_batch(x, ..., schema = NULL)
参数
- x
要转换为 Arrow RecordBatch 的对象
- ...
传递给 S3 方法
- schema
一个 Schema,或者
NULL
(默认值)表示从...
中的数据推断 schema。当提供 Arrow IPC 缓冲区时,需要提供schema
。
返回值
一个 RecordBatch
示例
# use as_record_batch() for a single object
as_record_batch(data.frame(col1 = 1, col2 = "two"))
#> RecordBatch
#> 1 rows x 2 columns
#> $col1 <double>
#> $col2 <string>
#>
#> See $metadata for additional Schema metadata
# use record_batch() to create from columns
record_batch(col1 = 1, col2 = "two")
#> RecordBatch
#> 1 rows x 2 columns
#> $col1 <double>
#> $col2 <string>