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

Function can_reuse_memory

r/src/r_to_arrow.cpp:1208–1224  ·  view source on GitHub ↗

in some situations we can just use the memory of the R object in an RBuffer instead of going through ArrayBuilder, etc ...

Source from the content-addressed store, hash-verified

1206// in some situations we can just use the memory of the R object in an RBuffer
1207// instead of going through ArrayBuilder, etc ...
1208bool can_reuse_memory(SEXP x, const std::shared_ptr<arrow::DataType>& type) {
1209 // TODO: this probably should be disabled when x is an ALTREP object
1210 // because MakeSimpleArray below will force materialization
1211 switch (type->id()) {
1212 case Type::INT32:
1213 return TYPEOF(x) == INTSXP && !Rf_isObject(x);
1214 case Type::DOUBLE:
1215 return TYPEOF(x) == REALSXP && !Rf_isObject(x);
1216 case Type::INT8:
1217 return TYPEOF(x) == RAWSXP && !Rf_isObject(x);
1218 case Type::INT64:
1219 return TYPEOF(x) == REALSXP && Rf_inherits(x, "integer64");
1220 default:
1221 break;
1222 }
1223 return false;
1224}
1225
1226// this is only used on some special cases when the arrow Array can just use the memory of
1227// the R object, via an RBuffer, hence be zero copy

Callers 1

Calls 1

idMethod · 0.45

Tested by

no test coverage detected