eddelbuettel commented on PR #692:
URL: https://github.com/apache/arrow-nanoarrow/pull/692#issuecomment-2542250701
This is nice. When running with numeric vectors it is even closer to
zero-copy as it looks like as we retain the buffer:
```r
> library(nanoarrow)
> df <- data.frame(x = 1:10)
> df$matrix_col <- matrix(1:20, ncol = 2, byrow = TRUE)
> array <- as_nanoarrow_array(df)
> array
<nanoarrow_array struct[10]>
$ length : int 10
$ null_count: int 0
$ offset : int 0
$ buffers :List of 1
..$ :<nanoarrow_buffer validity<bool>[null] ``
$ children :List of 2
..$ x :<nanoarrow_array int32[10]>
.. ..$ length : int 10
.. ..$ null_count: int 0
.. ..$ offset : int 0
.. ..$ buffers :List of 2
.. .. ..$ :<nanoarrow_buffer validity<bool>[null] ``
.. .. ..$ :<nanoarrow_buffer data<int32>[10][40 b]> `1 2 3 4 5 6 7 8 9 10`
.. ..$ dictionary: NULL
.. ..$ children : list()
..$ matrix_col:<nanoarrow_array fixed_size_list(2)[10]>
.. ..$ length : int 10
.. ..$ null_count: int 0
.. ..$ offset : int 0
.. ..$ buffers :List of 1
.. .. ..$ :<nanoarrow_buffer validity<bool>[null] ``
.. ..$ children :List of 1
.. .. ..$ item:<nanoarrow_array int32[20]>
.. .. .. ..$ length : int 20
.. .. .. ..$ null_count: int 0
.. .. .. ..$ offset : int 0
.. .. .. ..$ buffers :List of 2
.. .. .. .. ..$ :<nanoarrow_buffer validity<bool>[null] ``
.. .. .. .. ..$ :<nanoarrow_buffer data<int32>[20][80 b]> `1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16 17 18 19 20`
.. .. .. ..$ dictionary: NULL
.. .. .. ..$ children : list()
.. ..$ dictionary: NULL
$ dictionary: NULL
>
> convert_array(array, tibble::tibble(x = integer(), matrix_col =
matrix(integer(), ncol = 2)))
# A tibble: 10 × 2
x matrix_col[,1] [,2]
<int> <int> <int>
1 1 1 2
2 2 3 4
3 3 5 6
4 4 7 8
5 5 9 10
6 6 11 12
7 7 13 14
8 8 15 16
9 9 17 18
10 10 19 20
>
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]