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

Method Next

cpp/src/arrow/compute/exec.cc:406–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404}
405
406bool ExecSpanIterator::Next(ExecSpan* span) {
407 if (!initialized_) {
408 span->length = 0;
409
410 // The first time this is called, we populate the output span with any
411 // Scalar or Array arguments in the ExecValue struct, and then just
412 // increment array offsets below. If any arguments are ChunkedArray, then
413 // the internal ArraySpans will see their members updated during the
414 // iteration
415 span->values.resize(args_->size());
416 for (size_t i = 0; i < args_->size(); ++i) {
417 const Datum& arg = (*args_)[i];
418 if (arg.is_scalar()) {
419 span->values[i].SetScalar(arg.scalar().get());
420 } else if (arg.is_array()) {
421 const ArrayData& arr = *arg.array();
422 span->values[i].SetArray(arr);
423 value_offsets_[i] = arr.offset;
424 } else {
425 // Populate members from the first chunk
426 const ChunkedArray& carr = *arg.chunked_array();
427 if (carr.num_chunks() > 0) {
428 const ArrayData& arr = *carr.chunk(0)->data();
429 span->values[i].SetArray(arr);
430 value_offsets_[i] = arr.offset;
431 } else {
432 // Fill as zero-length array
433 ::arrow::internal::FillZeroLengthArray(carr.type().get(),
434 &span->values[i].array);
435 span->values[i].scalar = nullptr;
436 }
437 have_chunked_arrays_ = true;
438 }
439 }
440
441 if (have_all_scalars_ && promote_if_all_scalars_) {
442 PromoteExecSpanScalars(span);
443 }
444
445 initialized_ = true;
446 } else if (position_ == length_) {
447 // We've emitted at least one span and we're at the end so we are done
448 return false;
449 }
450
451 // Determine how large the common contiguous "slice" of all the arguments is
452 int64_t iteration_size = std::min(length_ - position_, max_chunksize_);
453 if (have_chunked_arrays_) {
454 iteration_size = GetNextChunkSpan(iteration_size, span);
455 }
456
457 // Now, adjust the span
458 span->length = iteration_size;
459 for (size_t i = 0; i < args_->size(); ++i) {
460 const Datum& arg = args_->at(i);
461 if (!arg.is_scalar()) {
462 ArraySpan* arr = &span->values[i].array;
463 arr->SetSlice(value_positions_[i] + value_offsets_[i], iteration_size);

Callers 15

AssertReaderClosedMethod · 0.45
TEST_FFunction · 0.45
AssertReaderClosedMethod · 0.45
CheckIterationMethod · 0.45
TEST_FFunction · 0.45
ExecuteSpansMethod · 0.45
ExecuteNonSpansMethod · 0.45
ExecuteMethod · 0.45
ExecuteMethod · 0.45
BM_AddDispatchFunction · 0.45
NaiveSumPartialFunction · 0.45
NaiveMinMaxFunction · 0.45

Calls 15

FillZeroLengthArrayFunction · 0.85
PromoteExecSpanScalarsFunction · 0.85
resizeMethod · 0.80
is_scalarMethod · 0.80
SetScalarMethod · 0.80
is_arrayMethod · 0.80
chunked_arrayMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45
scalarMethod · 0.45
arrayMethod · 0.45
SetArrayMethod · 0.45

Tested by 11

AssertReaderClosedMethod · 0.36
TEST_FFunction · 0.36
AssertReaderClosedMethod · 0.36
CheckIterationMethod · 0.36
TEST_FFunction · 0.36
NaiveSumPartialFunction · 0.36
NaiveMinMaxFunction · 0.36
NaiveModeFunction · 0.36
WelfordVarFunction · 0.36
SimpleScalarArrayCompareFunction · 0.36