將 array_stream
轉換為 to
指定的類型。這是一個底層介面;除非需要更精細地控制轉換,否則大多數使用者應使用 as.data.frame()
或 as.vector()
。請參閱 convert_array()
以了解轉換過程的詳細資訊;請參閱 infer_nanoarrow_ptype()
以了解 to
的預設推斷。
用法
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
以根據第一個 schema 猜測。- 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
#>