| 781 | class ScalarExecutor : public KernelExecutorImpl<ScalarKernel> { |
| 782 | public: |
| 783 | Status Execute(const ExecBatch& batch, ExecListener* listener) override { |
| 784 | RETURN_NOT_OK(span_iterator_.Init(batch, exec_context()->exec_chunksize())); |
| 785 | |
| 786 | if (batch.length == 0) { |
| 787 | // For zero-length batches, we do nothing except return a zero-length |
| 788 | // array of the correct output type |
| 789 | ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Array> result, |
| 790 | MakeArrayOfNull(output_type_.GetSharedPtr(), /*length=*/0, |
| 791 | exec_context()->memory_pool())); |
| 792 | return EmitResult(result->data(), listener); |
| 793 | } |
| 794 | |
| 795 | // If the executor is configured to produce a single large Array output for |
| 796 | // kernels supporting preallocation, then we do so up front and then |
| 797 | // iterate over slices of that large array. Otherwise, we preallocate prior |
| 798 | // to processing each span emitted from the ExecSpanIterator |
| 799 | RETURN_NOT_OK(SetupPreallocation(span_iterator_.length(), batch.values)); |
| 800 | |
| 801 | // ARROW-16756: Here we have to accommodate the distinct cases |
| 802 | // |
| 803 | // * Fully-preallocated contiguous output |
| 804 | // * Fully-preallocated, non-contiguous kernel output |
| 805 | // * Not-fully-preallocated kernel output: we pass an empty or |
| 806 | // partially-filled ArrayData to the kernel |
| 807 | if (preallocating_all_buffers_) { |
| 808 | return ExecuteSpans(listener); |
| 809 | } else { |
| 810 | return ExecuteNonSpans(listener); |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | Datum WrapResults(const std::vector<Datum>& inputs, |
| 815 | const std::vector<Datum>& outputs) override { |
nothing calls this directly
no test coverage detected