arrow-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neal Richardson <neal.p.richard...@gmail.com>
Subject Re: [R and C++] passing arrow::Arrow from R to C++ for reading and writing?
Date Mon, 12 Oct 2020 15:09:44 GMT
Hi Colin,
Does the code you shared run? If not, how does it fail?

One guess is that you're probably getting undefined symbols errors because
you need more than just -larrow. See
https://github.com/apache/arrow/blob/master/r/configure#L35 for others you
need, and depending on how you installed arrow, you likely also need
-larrow_bundled_dependencies.

Neal

On Mon, Oct 12, 2020 at 1:49 AM Colin McLean <cmclean5@staffmail.ed.ac.uk>
wrote:

> Dear Arrow users,
>
>   I was wondering if anyone can help me understand how I can create an
> arrow::Array object in R, then pass this into C++ (using the Rcpp
> library) for both reading and writing too? Similar what is done using
> the R bigmemory
> (https://privefl.github.io/blog/Tip-Optimize-your-Rcpp-loops/) or
> bigstatsr packages.
>
> Kindest Regards,
> Colin Mclean.
>
> R script:
> library(Rcpp)
> library(arrow)
>
> ## compile c++ code
> Sys.setenv("PKG_CXXFLAGS" = "-larrow")
> sourceCpp("utils.cpp")
>
> N = 10
> X = arrow::Array$create(rep(0,N*N))
>
> test( X$pointer() )
>
>
> utils.cpp:
> // define headers
> // [[Rcpp::plugins(cpp11)]]
> // [[Rcpp::depends(arrow)]]
>
> #include <arrow/api.h>
> #include <arrow/array.h>
> #include <arrow/array/array_base.h>
> #include <Rcpp.h>
> #include <stdio.h>
> #include <iostream>
> #include <string>
>
>
> using namespace Rcpp;
> using namespace std;
>
> // [[Rcpp::export]]
> void test( XPtr<arrow::Array> aAPtr ){
>
>    cout << "read & write arrow::Array in test " << endl;
>    cout << aAPtr << endl;
>
> }
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
>

Mime
View raw message