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

Method Dataptr_or_null

r/src/altrep.cpp:221–237  ·  view source on GitHub ↗

R calls this to get a pointer to the start of the vector data but only if this is possible without allocating (in the R sense).

Source from the content-addressed store, hash-verified

219 // R calls this to get a pointer to the start of the vector data
220 // but only if this is possible without allocating (in the R sense).
221 static const void* Dataptr_or_null(SEXP alt) {
222 // data2 has been created, and so the R sentinels are in place where the array has
223 // nulls
224 if (IsMaterialized(alt)) {
225 return DATAPTR_RO(Representation(alt));
226 }
227
228 // there is only one chunk with no nulls, we can directly return the start of its data
229 auto chunked_array = GetChunkedArray(alt);
230 if (chunked_array->num_chunks() == 1 && chunked_array->null_count() == 0) {
231 return reinterpret_cast<const void*>(
232 chunked_array->chunk(0)->data()->template GetValues<c_type>(1));
233 }
234
235 // Otherwise: if the array has nulls and data2 has not been generated: give up
236 return nullptr;
237 }
238
239 // R calls this to get a pointer to the start of the data, R allocations are allowed.
240 static void* Dataptr(SEXP alt, Rboolean writeable) {

Callers

nothing calls this directly

Calls 3

num_chunksMethod · 0.45
null_countMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected