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

Method Get_region

r/src/altrep.cpp:290–330  ·  view source on GitHub ↗

R calls this when it wants data from position `i` to `i + n` copied into `buf` The returned value is the number of values that were really copied (this can be lower than n)

Source from the content-addressed store, hash-verified

288 // The returned value is the number of values that were really copied
289 // (this can be lower than n)
290 static R_xlen_t Get_region(SEXP alt, R_xlen_t i, R_xlen_t n, c_type* buf) {
291 // If we have data2, we can just copy the region into buf
292 // using the standard Get_region for this R type
293 if (IsMaterialized(alt)) {
294 return Standard_Get_region<c_type>(Representation(alt), i, n, buf);
295 }
296
297 // The vector was not materialized, aka we don't have data2
298 //
299 // In that case, we copy the data from the Array, and then
300 // do a second pass to force the R sentinels for where the
301 // array has nulls
302 //
303 // This only materializes the region into buf (not the entire vector).
304 auto slice = GetChunkedArray(alt)->Slice(i, n);
305 R_xlen_t ncopy = slice->length();
306
307 c_type* out = buf;
308 for (const auto& array : slice->chunks()) {
309 auto n_i = array->length();
310
311 // first copy the data buffer
312 memcpy(out, array->data()->template GetValues<c_type>(1), n_i * sizeof(c_type));
313
314 // then set the R NA sentinels if needed
315 if (array->null_count() > 0) {
316 internal::BitmapReader bitmap_reader(array->null_bitmap()->data(),
317 array->offset(), n_i);
318
319 for (R_xlen_t j = 0; j < n_i; j++, bitmap_reader.Next()) {
320 if (bitmap_reader.IsNotSet()) {
321 out[j] = cpp11::na<c_type>();
322 }
323 }
324 }
325
326 out += n_i;
327 }
328
329 return ncopy;
330 }
331
332 static std::shared_ptr<arrow::compute::ScalarAggregateOptions> NaRmOptions(bool na_rm) {
333 auto options = std::make_shared<arrow::compute::ScalarAggregateOptions>(

Callers

nothing calls this directly

Calls 8

SliceMethod · 0.45
lengthMethod · 0.45
chunksMethod · 0.45
dataMethod · 0.45
null_countMethod · 0.45
offsetMethod · 0.45
NextMethod · 0.45
IsNotSetMethod · 0.45

Tested by

no test coverage detected