[[arrow::export]]
| 1197 | |
| 1198 | // [[arrow::export]] |
| 1199 | sexp test_arrow_altrep_copy_by_region(sexp x, R_xlen_t region_size) { |
| 1200 | if (!is_arrow_altrep(x)) { |
| 1201 | stop("x is not arrow ALTREP"); |
| 1202 | } |
| 1203 | |
| 1204 | R_xlen_t n = Rf_xlength(x); |
| 1205 | |
| 1206 | if (TYPEOF(x) == INTSXP) { |
| 1207 | cpp11::writable::integers out(Rf_xlength(x)); |
| 1208 | cpp11::writable::integers buf_shelter(region_size); |
| 1209 | int* buf = INTEGER(buf_shelter); |
| 1210 | for (R_xlen_t i = 0; i < n; i++) { |
| 1211 | if ((i % region_size) == 0) { |
| 1212 | INTEGER_GET_REGION(x, i, region_size, buf); |
| 1213 | } |
| 1214 | out[i] = buf[i % region_size]; |
| 1215 | } |
| 1216 | return out; |
| 1217 | } else if (TYPEOF(x) == REALSXP) { |
| 1218 | cpp11::writable::doubles out(Rf_xlength(x)); |
| 1219 | cpp11::writable::doubles buf_shelter(region_size); |
| 1220 | double* buf = REAL(buf_shelter); |
| 1221 | for (R_xlen_t i = 0; i < n; i++) { |
| 1222 | if ((i % region_size) == 0) { |
| 1223 | REAL_GET_REGION(x, i, region_size, buf); |
| 1224 | } |
| 1225 | out[i] = buf[i % region_size]; |
| 1226 | } |
| 1227 | return out; |
| 1228 | } else { |
| 1229 | return R_NilValue; |
| 1230 | } |
| 1231 | } |
| 1232 | |
| 1233 | // [[arrow::export]] |
| 1234 | sexp test_arrow_altrep_copy_by_dataptr(sexp x) { |
no test coverage detected