The value at position i
| 262 | |
| 263 | // The value at position i |
| 264 | static c_type Elt(SEXP alt, R_xlen_t i) { |
| 265 | if (IsMaterialized(alt)) { |
| 266 | if constexpr (std::is_same_v<c_type, double>) { |
| 267 | return REAL(Representation(alt))[i]; |
| 268 | } else if constexpr (std::is_same_v<c_type, int>) { |
| 269 | return INTEGER(Representation(alt))[i]; |
| 270 | } else { |
| 271 | static_assert(std::is_same_v<c_type, double> || std::is_same_v<c_type, int>, |
| 272 | "ALTREP not implemented for this c_type"); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | auto altrep_data = |
| 277 | reinterpret_cast<ArrowAltrepData*>(R_ExternalPtrAddr(R_altrep_data1(alt))); |
| 278 | auto resolve = altrep_data->locate(i); |
| 279 | const auto& array = |
| 280 | altrep_data->chunked_array()->chunk(static_cast<int>(resolve.chunk_index)); |
| 281 | auto j = resolve.index_in_chunk; |
| 282 | |
| 283 | return array->IsNull(j) ? cpp11::na<c_type>() |
| 284 | : array->data()->template GetValues<c_type>(1)[j]; |
| 285 | } |
| 286 | |
| 287 | // R calls this when it wants data from position `i` to `i + n` copied into `buf` |
| 288 | // The returned value is the number of values that were really copied |
nothing calls this directly
no test coverage detected