jonkeane commented on code in PR #45951: URL: https://github.com/apache/arrow/pull/45951#discussion_r2019797949
########## 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: I believe this chunk is necessary to return the array of strings here. But oddly(??) when I tried this block as simply `return STRING_ELT(vec, 0);` (which would return just the first element IIUC), all tests passed. So maybe I misunderstand what's happening in the MutableBuffer there and we actually only need an object of the right type? Or we don't have test coverage that ensures that the full vector is there? -- 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