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

Method ScheduleConvertTasks

r/src/array_to_vector.cpp:73–104  ·  view source on GitHub ↗

converter is passed as self to outlive the scope of Converter::Convert()

Source from the content-addressed store, hash-verified

71
72 // converter is passed as self to outlive the scope of Converter::Convert()
73 SEXP ScheduleConvertTasks(RTasks& tasks, std::shared_ptr<Converter> self) {
74 // try altrep first
75 SEXP alt = altrep::MakeAltrepVector(chunked_array_);
76 if (!Rf_isNull(alt)) {
77 return alt;
78 }
79
80 // otherwise use the Converter api:
81
82 // allocating the R vector upfront
83 SEXP out = PROTECT(Allocate(chunked_array_->length()));
84
85 // for each array, fill the relevant slice of `out`, potentially in parallel
86 R_xlen_t k = 0, i = 0;
87 for (const auto& array : chunked_array_->chunks()) {
88 auto n_chunk = array->length();
89
90 tasks.Append(Parallel(), [=] {
91 if (array->null_count() == n_chunk) {
92 return self->Ingest_all_nulls(out, k, n_chunk);
93 } else {
94 return self->Ingest_some_nulls(out, array, k, n_chunk, i);
95 }
96 });
97
98 k += n_chunk;
99 i++;
100 }
101
102 UNPROTECT(1);
103 return out;
104 }
105
106 // Convert a slice of the data this converter was built for (e.g. one element of a
107 // list array) to a standalone R vector, reusing the decisions this converter made

Callers 1

LazyConvertMethod · 0.80

Calls 8

MakeAltrepVectorFunction · 0.85
AllocateFunction · 0.85
lengthMethod · 0.45
chunksMethod · 0.45
AppendMethod · 0.45
null_countMethod · 0.45
Ingest_all_nullsMethod · 0.45
Ingest_some_nullsMethod · 0.45

Tested by

no test coverage detected