[[arrow::export]]
| 1166 | |
| 1167 | // [[arrow::export]] |
| 1168 | sexp test_arrow_altrep_copy_by_element(sexp x) { |
| 1169 | if (!is_arrow_altrep(x)) { |
| 1170 | stop("x is not arrow ALTREP"); |
| 1171 | } |
| 1172 | |
| 1173 | R_xlen_t n = Rf_xlength(x); |
| 1174 | |
| 1175 | if (TYPEOF(x) == INTSXP) { |
| 1176 | cpp11::writable::integers out(Rf_xlength(x)); |
| 1177 | for (R_xlen_t i = 0; i < n; i++) { |
| 1178 | out[i] = INTEGER_ELT(x, i); |
| 1179 | } |
| 1180 | return out; |
| 1181 | } else if (TYPEOF(x) == REALSXP) { |
| 1182 | cpp11::writable::doubles out(Rf_xlength(x)); |
| 1183 | for (R_xlen_t i = 0; i < n; i++) { |
| 1184 | out[i] = REAL_ELT(x, i); |
| 1185 | } |
| 1186 | return out; |
| 1187 | } else if (TYPEOF(x) == STRSXP) { |
| 1188 | cpp11::writable::strings out(Rf_xlength(x)); |
| 1189 | for (R_xlen_t i = 0; i < n; i++) { |
| 1190 | out[i] = STRING_ELT(x, i); |
| 1191 | } |
| 1192 | return out; |
| 1193 | } else { |
| 1194 | return R_NilValue; |
| 1195 | } |
| 1196 | } |
| 1197 | |
| 1198 | // [[arrow::export]] |
| 1199 | sexp test_arrow_altrep_copy_by_region(sexp x, R_xlen_t region_size) { |
no test coverage detected