MCPcopy Create free account
hub / github.com/apache/arrow / Extend

Method Extend

r/src/r_to_arrow.cpp:279–303  ·  view source on GitHub ↗

This is not run in parallel by default, so it's safe to call into R here; however, it is not safe to throw an exception here because the caller might be waiting for other conversions to finish in the background. To avoid this, use StatusUnwindProtect() to communicate the error back to ValueOrStop() (which reconstructs the exception and re-throws it).

Source from the content-addressed store, hash-verified

277 // avoid this, use StatusUnwindProtect() to communicate the error back to
278 // ValueOrStop() (which reconstructs the exception and re-throws it).
279 Status Extend(SEXP values, int64_t size, int64_t offset = 0) {
280 try {
281 cpp11::sexp as_array_result = cpp11::package("arrow")["as_arrow_array"](
282 values, cpp11::named_arg("type") = cpp11::as_sexp(options().type),
283 cpp11::named_arg("from_vec_to_array") = cpp11::as_sexp<bool>(true));
284
285 // Check that the R method returned an Array
286 if (!Rf_inherits(as_array_result, "Array")) {
287 return Status::Invalid("as_arrow_array() did not return object of type Array");
288 }
289
290 auto array = cpp11::as_cpp<std::shared_ptr<arrow::Array>>(as_array_result);
291
292 // We need the type to be equal because the schema has already been finalized
293 if (!array->type()->Equals(options().type)) {
294 return Status::Invalid(
295 "as_arrow_array() returned an Array with an incorrect type");
296 }
297
298 arrays_.push_back(std::move(array));
299 return Status::OK();
300 } catch (cpp11::unwind_exception& e) {
301 return StatusUnwindProtect(e.token, "calling as_arrow_array()");
302 }
303 }
304
305 // This is sometimes run in parallel so we can't call into R
306 Result<std::shared_ptr<ChunkedArray>> ToChunkedArray() {

Callers

nothing calls this directly

Calls 8

as_sexpFunction · 0.85
optionsFunction · 0.85
StatusUnwindProtectFunction · 0.85
push_backMethod · 0.80
InvalidClass · 0.50
OKFunction · 0.50
EqualsMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected