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

Method ScheduleConvertTasks

r/src/array_to_vector.cpp:66–97  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

64
65 // converter is passed as self to outlive the scope of Converter::Convert()
66 SEXP ScheduleConvertTasks(RTasks& tasks, std::shared_ptr<Converter> self) {
67 // try altrep first
68 SEXP alt = altrep::MakeAltrepVector(chunked_array_);
69 if (!Rf_isNull(alt)) {
70 return alt;
71 }
72
73 // otherwise use the Converter api:
74
75 // allocating the R vector upfront
76 SEXP out = PROTECT(Allocate(chunked_array_->length()));
77
78 // for each array, fill the relevant slice of `out`, potentially in parallel
79 R_xlen_t k = 0, i = 0;
80 for (const auto& array : chunked_array_->chunks()) {
81 auto n_chunk = array->length();
82
83 tasks.Append(Parallel(), [=] {
84 if (array->null_count() == n_chunk) {
85 return self->Ingest_all_nulls(out, k, n_chunk);
86 } else {
87 return self->Ingest_some_nulls(out, array, k, n_chunk, i);
88 }
89 });
90
91 k += n_chunk;
92 i++;
93 }
94
95 UNPROTECT(1);
96 return out;
97 }
98
99 // Converter factory
100 static std::shared_ptr<Converter> Make(

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