[[arrow::export]]
| 1232 | |
| 1233 | // [[arrow::export]] |
| 1234 | sexp 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 | } |
no test coverage detected