| 342 | } // namespace |
| 343 | |
| 344 | Status ExecSpanIterator::Init(const ExecBatch& batch, int64_t max_chunksize, |
| 345 | bool promote_if_all_scalars) { |
| 346 | if (batch.num_values() > 0) { |
| 347 | // Validate arguments |
| 348 | bool all_args_same_length = false; |
| 349 | int64_t inferred_length = InferBatchLength(batch.values, &all_args_same_length); |
| 350 | if (inferred_length != batch.length) { |
| 351 | return Status::Invalid("Value lengths differed from ExecBatch length"); |
| 352 | } |
| 353 | if (!all_args_same_length) { |
| 354 | return Status::Invalid("Array arguments must all be the same length"); |
| 355 | } |
| 356 | } |
| 357 | args_ = &batch.values; |
| 358 | initialized_ = have_chunked_arrays_ = false; |
| 359 | have_all_scalars_ = CheckIfAllScalar(batch); |
| 360 | promote_if_all_scalars_ = promote_if_all_scalars; |
| 361 | position_ = 0; |
| 362 | length_ = batch.length; |
| 363 | chunk_indexes_.clear(); |
| 364 | chunk_indexes_.resize(args_->size(), 0); |
| 365 | value_positions_.clear(); |
| 366 | value_positions_.resize(args_->size(), 0); |
| 367 | value_offsets_.clear(); |
| 368 | value_offsets_.resize(args_->size(), 0); |
| 369 | max_chunksize_ = std::min(length_, max_chunksize); |
| 370 | return Status::OK(); |
| 371 | } |
| 372 | |
| 373 | int64_t ExecSpanIterator::GetNextChunkSpan(int64_t iteration_size, ExecSpan* span) { |
| 374 | for (size_t i = 0; i < args_->size() && iteration_size > 0; ++i) { |