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

Method SetMembers

cpp/src/arrow/array/data.cc:286–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284// Methods for ArraySpan
285
286void ArraySpan::SetMembers(const ArrayData& data) {
287 this->type = data.type.get();
288 this->length = data.length;
289 if (this->type->id() == Type::NA) {
290 this->null_count = this->length;
291 } else {
292 this->null_count = data.null_count.load();
293 }
294 this->offset = data.offset;
295
296 for (int i = 0; i < std::min(static_cast<int>(data.buffers.size()), 3); ++i) {
297 const std::shared_ptr<Buffer>& buffer = data.buffers[i];
298 // It is the invoker-of-kernels's responsibility to ensure that
299 // const buffers are not written to accidentally.
300 if (buffer) {
301 SetBuffer(i, buffer);
302 } else {
303 this->buffers[i] = {};
304 }
305 }
306
307 Type::type type_id = this->type->id();
308 if (type_id == Type::EXTENSION) {
309 auto* ext_type = checked_cast<const ExtensionType*>(this->type);
310 type_id = ext_type->storage_type()->id();
311 }
312
313 if ((data.buffers.size() == 0 || data.buffers[0] == nullptr) && type_id != Type::NA &&
314 type_id != Type::SPARSE_UNION && type_id != Type::DENSE_UNION) {
315 // This should already be zero but we make for sure
316 this->null_count = 0;
317 }
318
319 // Makes sure any other buffers are seen as null / nonexistent
320 for (int i = static_cast<int>(data.buffers.size()); i < 3; ++i) {
321 this->buffers[i] = {};
322 }
323
324 if (type_id == Type::STRING_VIEW || type_id == Type::BINARY_VIEW) {
325 // store the span of data buffers in the third buffer
326 this->buffers[2] = internal::PackVariadicBuffers(std::span(data.buffers).subspan(2));
327 }
328
329 if (type_id == Type::DICTIONARY) {
330 this->child_data.resize(1);
331 this->child_data[0].SetMembers(*data.dictionary);
332 } else {
333 this->child_data.resize(data.child_data.size());
334 for (size_t child_index = 0; child_index < data.child_data.size(); ++child_index) {
335 this->child_data[child_index].SetMembers(*data.child_data[child_index]);
336 }
337 }
338}
339
340namespace {
341

Callers 11

FillFromScalarMethod · 0.80
CheckSpanRoundTripFunction · 0.80
TEST_FFunction · 0.80
ExecValueMethod · 0.80
SetArrayMethod · 0.80
ExecuteSpansMethod · 0.80
BM_CastDispatchBaselineFunction · 0.80
BM_AddDispatchFunction · 0.80
ExecMethod · 0.80
ExecScalarCaseWhenFunction · 0.80
PairwiseExecImplFunction · 0.80

Calls 8

SetBufferFunction · 0.85
PackVariadicBuffersFunction · 0.85
storage_typeMethod · 0.80
resizeMethod · 0.80
getMethod · 0.45
idMethod · 0.45
loadMethod · 0.45
sizeMethod · 0.45

Tested by 2

CheckSpanRoundTripFunction · 0.64
TEST_FFunction · 0.64