| 1068 | class RListConverter : public ListConverter<T, RConverter, RConverterTrait> { |
| 1069 | public: |
| 1070 | Status Extend(SEXP x, int64_t size, int64_t offset = 0) override { |
| 1071 | RETURN_NOT_OK(this->Reserve(size)); |
| 1072 | |
| 1073 | RVectorType rtype = GetVectorType(x); |
| 1074 | if (rtype != LIST) { |
| 1075 | return Status::Invalid("Cannot convert to list type"); |
| 1076 | } |
| 1077 | |
| 1078 | auto append_null = [this]() { return this->list_builder_->AppendNull(); }; |
| 1079 | |
| 1080 | auto append_value = [this](SEXP value) { |
| 1081 | // TODO: if we decide that this can be run concurrently |
| 1082 | // we'll have to do vec_size() upfront |
| 1083 | R_xlen_t n = arrow::r::vec_size(value); |
| 1084 | |
| 1085 | RETURN_NOT_OK(this->list_builder_->ValidateOverflow(n)); |
| 1086 | RETURN_NOT_OK(this->list_builder_->Append()); |
| 1087 | return this->value_converter_.get()->Extend(value, n); |
| 1088 | }; |
| 1089 | |
| 1090 | return VisitVector(RVectorIterator<SEXP>(x, offset), size, append_null, append_value); |
| 1091 | } |
| 1092 | |
| 1093 | void DelayedExtend(SEXP values, int64_t size, RTasks& tasks) override { |
| 1094 | // NOTE: because Extend::[]append_value() calls Extend() on the |
no test coverage detected