You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+68-6Lines changed: 68 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,24 @@
1
-
# arrow_extendr
1
+
# arrow-extendr
2
2
3
-
arrow-extendr is a crate that facilitates the transfer of [Apache Arrow](https://arrow.apache.org/) memory between R and Rust. It utilizes [extendr](https://extendr.github.io/), the [**`{nanoarrow}`**](https://arrow.apache.org/nanoarrow/0.3.0/r/index.html) R package, and [arrow-rs](https://docs.rs/arrow).
3
+
arrow-extendr is a crate that facilitates the transfer of [Apache Arrow](https://arrow.apache.org/) memory between R and Rust. It utilizes [extendr](https://extendr.github.io/) and [arrow-rs](https://docs.rs/arrow).
4
4
5
-
### Motivating Example
5
+
Arrow memory is exchanged via the [Arrow C Data Interface](https://arrow.apache.org/docs/format/CDataInterface.html) using R's `nanoarrow_array`, `nanoarrow_schema`, and `nanoarrow_array_stream` external pointer objects. The [`{nanoarrow}`](https://arrow.apache.org/nanoarrow/0.3.0/r/index.html) R package is **not** required as a dependency of your package.
6
+
7
+
## Features
8
+
9
+
| Feature | Description |
10
+
| ------- | ----------- |
11
+
|`arrow`| Core arrow-rs interop (default) |
12
+
|`geoarrow-08`| GeoArrow array support via geoarrow-array 0.8 |
13
+
|`polars`| Polars interop, alias for `polars-53`|
14
+
|`polars-53`| Polars interop for polars-core 0.53 |
15
+
|`polars-51`| Polars interop for polars-core 0.51 |
16
+
17
+
## Motivating Example
6
18
7
19
Say we have the following `DBI` connection which we will send requests to using arrow.
8
20
The result of `dbGetQueryArrow()` is a `nanoarrow_array_stream`. We want to
9
-
count the number of rows in each batch of the steam using Rust.
21
+
count the number of rows in each batch of the stream using Rust.
10
22
11
23
```r
12
24
# adapted from https://github.com/r-dbi/DBI/blob/main/vignettes/DBI-arrow.Rmd
@@ -67,6 +79,56 @@ process_stream(query)
67
79
#> [1] 2959
68
80
```
69
81
82
+
## GeoArrow interop
83
+
84
+
arrow-extendr supports [GeoArrow](https://geoarrow.org/) via the `geoarrow-08` feature flag, backed by the [geoarrow-array](https://docs.rs/geoarrow-array) crate.
85
+
86
+
```toml
87
+
arrow_extendr = { version = "58.0.1", features = ["geoarrow-08"] }
88
+
geoarrow-array = "0.8"
89
+
```
90
+
91
+
This enables the following conversions between Rust and R's `nanoarrow_array` objects:
92
+
93
+
| Type |`FromArrowRobj`|`ToArrowRobj`|`IntoArrowRobj`|
arrow-extendr provides optional interop with [Polars](https://docs.rs/polars) via versioned feature flags. Use the feature that matches your `polars-core` version:
@@ -135,10 +197,10 @@ To use arrow-extendr in an R package first create an R package and make it an ex
135
197
136
198
```r
137
199
usethis::create_package("my_package")
138
-
rextendr::use_extendr();
200
+
rextendr::use_extendr()
139
201
```
140
202
141
-
Next, you have to ensure that `nanoarrow` is a dependency of the package since arrow-extendr will call functions from nanoarrow to convert between R and Arrow memory. To do this run `usethis::use_package("nanoarrow")` to add it to your Imports field in the DESCRIPTION file.
203
+
arrow-extendr implements all Arrow C Data Interface pointer handling in pure Rust, so the `{nanoarrow}` R package is **not** required as a runtime dependency of your package. The pointer objects (`nanoarrow_array`, `nanoarrow_schema`, `nanoarrow_array_stream`) are standard R external pointers whose class names are set by arrow-extendr directly.
0 commit comments