jonkeane commented on code in PR #45951: URL: https://github.com/apache/arrow/pull/45951#discussion_r2021527879
########## r/src/arrow_types.h: ########## @@ -173,14 +173,33 @@ 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) { + // Technically this returns the address to the first element of the string vector Review Comment: _nods_ yeah, I agree this is weird! Did you see this comment (and especially the code block that was there, I've added below in case github folding hides it) https://github.com/apache/arrow/pull/45951#discussion_r2019797949 would this code be better here? ``` } 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; } ``` -- 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