jonkeane commented on code in PR #45951: URL: https://github.com/apache/arrow/pull/45951#discussion_r2020940864
########## r/src/arrow_types.h: ########## @@ -173,14 +173,39 @@ template <typename RVector> class RBuffer : public MutableBuffer { public: explicit RBuffer(RVector vec) - : MutableBuffer(reinterpret_cast<uint8_t*>(DATAPTR(vec)), + : MutableBuffer(reinterpret_cast<uint8_t*>(getDataPointer(vec)), vec.size() * sizeof(typename RVector::value_type), arrow::CPUDevice::memory_manager(gc_memory_pool())), vec_(vec) {} private: // vec_ holds the memory RVector vec_; + + static void* getDataPointer(RVector& vec) { + if (TYPEOF(vec) == LGLSXP) { + return LOGICAL(vec); + } else if (TYPEOF(vec) == INTSXP) { + return INTEGER(vec); + } else if (TYPEOF(vec) == REALSXP) { + return REAL(vec); + } else if (TYPEOF(vec) == CPLXSXP) { + return COMPLEX(vec); + } else if (TYPEOF(vec) == STRSXP) { + cpp11::writable::strings out(Rf_xlength(vec)); + R_xlen_t len = Rf_xlength(vec); + + for (R_xlen_t i = 0; i < len; i++) { + SEXP str_elt = reinterpret_cast<SEXP>(STRING_ELT(vec, i)); + out[i] = str_elt; + } + + return out; Review Comment: Ok, I've also commented this to be explicit for the next person -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org