Convert a slice of the data this converter was built for (e.g. one element of a list array) to a standalone R vector, reusing the decisions this converter made over all chunks (factor levels, integer vs double, ...). chunk_index is the index of the chunk that `slice` was taken from, so that per-chunk state (e.g. dictionary transposition) is applied correctly.
| 110 | // chunk_index is the index of the chunk that `slice` was taken from, so that |
| 111 | // per-chunk state (e.g. dictionary transposition) is applied correctly. |
| 112 | virtual SEXP ConvertSlice(const std::shared_ptr<Array>& slice, |
| 113 | size_t chunk_index) const { |
| 114 | // Dictionary slices must go through this converter so that they get the |
| 115 | // unified levels; other types can shadow the slice with altrep as before |
| 116 | if (slice->type_id() != Type::DICTIONARY) { |
| 117 | SEXP alt = altrep::MakeAltrepVector(std::make_shared<ChunkedArray>(slice)); |
| 118 | if (!Rf_isNull(alt)) { |
| 119 | return alt; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | R_xlen_t n = slice->length(); |
| 124 | SEXP out = PROTECT(AllocateSlice(n)); |
| 125 | if (slice->null_count() == n) { |
| 126 | StopIfNotOk(Ingest_all_nulls(out, 0, n)); |
| 127 | } else { |
| 128 | StopIfNotOk(Ingest_some_nulls(out, slice, 0, n, chunk_index)); |
| 129 | } |
| 130 | UNPROTECT(1); |
| 131 | return out; |
| 132 | } |
| 133 | |
| 134 | // Converter factory |
| 135 | static std::shared_ptr<Converter> Make( |
no test coverage detected