Commits


Romain Francois authored and Wes McKinney committed b541888ad67
ARROW-3439: [R] R language bindings for Feather format ``` r library(arrow, warn.conflicts = FALSE) library(tibble) tib <- tibble(x = 1:10, y = rnorm(10), z = letters[1:10]) tib #> # A tibble: 10 x 3 #> x y z #> <int> <dbl> <chr> #> 1 1 0.315 a #> 2 2 -1.16 b #> 3 3 0.0980 c #> 4 4 0.836 d #> 5 5 -1.12 e #> 6 6 0.118 f #> 7 7 2.74 g #> 8 8 -0.323 h #> 9 9 0.291 i #> 10 10 1.40 j tf <- tempfile() write_feather(tib, tf) # reads back into an arrow::Table tab1 <- read_feather(tf) tab1 #> arrow::Table # convert that to tibble as_tibble(tab1) #> # A tibble: 10 x 3 #> x y z #> <int> <dbl> <chr> #> 1 1 0.315 a #> 2 2 -1.16 b #> 3 3 0.0980 c #> 4 4 0.836 d #> 5 5 -1.12 e #> 6 6 0.118 f #> 7 7 2.74 g #> 8 8 -0.323 h #> 9 9 0.291 i #> 10 10 1.40 j identical(tib, as_tibble(tab1)) #> [1] TRUE # read it through reticulate library(reticulate) pa <- import("pyarrow") # read straight to a data frame via pyarrow.feather.read_feather tab2 <- pa$feather$read_feather(tf) # just so that we cna compare attr(tab2, "pandas.index") <- NULL tab2 #> x y z #> 1 1 0.3148670 a #> 2 2 -1.1583740 b #> 3 3 0.0980070 c #> 4 4 0.8360379 d #> 5 5 -1.1171395 e #> 6 6 0.1177422 f #> 7 7 2.7407804 g #> 8 8 -0.3229787 h #> 9 9 0.2910557 i #> 10 10 1.4015148 j identical(tib, as_tibble(tab2)) #> [1] TRUE ``` <sup>Created on 2018-11-12 by the [reprex package](https://reprex.tidyverse.org) (v0.2.1.9000)</sup> Author: Romain Francois <romain@purrple.cat> Closes #2947 from romainfrancois/ARROW-3439/feather and squashes the following commits: 8d708e21d <Romain Francois> added `mmap` argument to all methods of feather_table_reader fd1b7d5b5 <Romain Francois> additional test using mmap_open() and file_open() directly da9df5d69 <Romain Francois> + feather prefix -> feather_table_writer and feather_table_reader d5f886d19 <Romain Francois> Add mmap argument to table_reader so that character method uses mmap_open instead of file_open if mmap = TRUE 14b169dd6 <Romain Francois> until we figure out how to probably do double dispatch and 🤐 check 43cab0629 <Romain Francois> Fixes for write_feather 2a62b7222 <Romain Francois> using construct and STOP_IF_NOT_OK (rebase) 8825b3e5b <Romain Francois> lint 🤷 ♀️ a144cfd73 <Romain Francois> exposing feather::TableReader 61fec7187 <Romain Francois> 👶 support for feather::TableWriter 432588cf6 <Romain Francois> Message and MessageReader 7751a1c18 <Romain Francois> s/construct/shared_ptr/, add unique_ptr R function. support for unique_ptr. 8a695b881 <Romain Francois> lint df5fdba49 <Romain Francois> R6 class support for arrow::ipc::Message backed by a unique_ptr 56ff849f3 <Romain Francois> using struct input_parameter<const std::shared_ptr<T>& instead of the heavier Exporter class