MCPcopy Create free account
hub / github.com/apache/arrow / test_arrow_altrep_copy_by_dataptr

Function test_arrow_altrep_copy_by_dataptr

r/src/altrep.cpp:1234–1258  ·  view source on GitHub ↗

[[arrow::export]]

Source from the content-addressed store, hash-verified

1232
1233// [[arrow::export]]
1234sexp test_arrow_altrep_copy_by_dataptr(sexp x) {
1235 if (!is_arrow_altrep(x)) {
1236 stop("x is not arrow ALTREP");
1237 }
1238
1239 R_xlen_t n = Rf_xlength(x);
1240
1241 if (TYPEOF(x) == INTSXP) {
1242 cpp11::writable::integers out(Rf_xlength(x));
1243 int* ptr = INTEGER(x);
1244 for (R_xlen_t i = 0; i < n; i++) {
1245 out[i] = ptr[i];
1246 }
1247 return out;
1248 } else if (TYPEOF(x) == REALSXP) {
1249 cpp11::writable::doubles out(Rf_xlength(x));
1250 double* ptr = REAL(x);
1251 for (R_xlen_t i = 0; i < n; i++) {
1252 out[i] = ptr[i];
1253 }
1254 return out;
1255 } else {
1256 return R_NilValue;
1257 }
1258}

Calls 2

is_arrow_altrepFunction · 0.85
stopFunction · 0.85

Tested by

no test coverage detected