将 array_stream 转换为 to 指定的类型。这是一个低级接口;除非需要对转换进行更精细的控制,否则大多数用户应该使用 as.data.frame() 或 as.vector()。有关转换过程的详细信息,请参阅 convert_array();有关 to 的默认推断,请参阅 infer_nanoarrow_ptype()。
用法
convert_array_stream(array_stream, to = NULL, size = NULL, n = Inf)
collect_array_stream(array_stream, n = Inf, schema = NULL, validate = TRUE)参数
- array_stream
- to
一个目标原型对象,描述了 `array` 应该被转换成的类型,或者 `NULL` 以使用由 ` infer_nanoarrow_ptype() ` 返回的默认转换。另外,可以传递一个函数来执行对 `array` 和原型的默认推断的默认 ptype 的替代计算。
- size
如果已知,输出的精确大小。如果指定,可以使用稍微更高效的实现来收集输出。
- n
从数组流中拉取的最大批次数量。
- schema
一个 nanoarrow_schema 或
NULL(基于第一个模式进行猜测)。- validate
使用
FALSE跳过验证步骤(即,如果您知道数组有效)。
返回值
convert_array_stream(): 类型为to的 R 向量。collect_array_stream(): nanoarrow_array 的list()
示例
stream <- as_nanoarrow_array_stream(data.frame(x = 1:5))
str(convert_array_stream(stream))
#> 'data.frame': 5 obs. of 1 variable:
#> $ x: int 1 2 3 4 5
str(convert_array_stream(stream, to = data.frame(x = double())))
#> 'data.frame': 0 obs. of 1 variable:
#> $ x: num
stream <- as_nanoarrow_array_stream(data.frame(x = 1:5))
collect_array_stream(stream)
#> [[1]]
#> <nanoarrow_array struct[5]>
#> $ length : int 5
#> $ null_count: int 0
#> $ offset : int 0
#> $ buffers :List of 1
#> ..$ :<nanoarrow_buffer validity<bool>[null] ``
#> $ children :List of 1
#> ..$ x:<nanoarrow_array int32[5]>
#> .. ..$ length : int 5
#> .. ..$ null_count: int 0
#> .. ..$ offset : int 0
#> .. ..$ buffers :List of 2
#> .. .. ..$ :<nanoarrow_buffer validity<bool>[null] ``
#> .. .. ..$ :<nanoarrow_buffer data<int32>[5][20 b]> `1 2 3 4 5`
#> .. ..$ dictionary: NULL
#> .. ..$ children : list()
#> $ dictionary: NULL
#>