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

Method PrepareOutput

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

Prepare an output ArrayData to be written to. If Kernel::mem_allocation is not MemAllocation::PREALLOCATE, then no data buffers will be set

Source from the content-addressed store, hash-verified

727 // Kernel::mem_allocation is not MemAllocation::PREALLOCATE, then no
728 // data buffers will be set
729 Result<std::shared_ptr<ArrayData>> PrepareOutput(int64_t length) {
730 auto out = std::make_shared<ArrayData>(output_type_.GetSharedPtr(), length);
731 out->buffers.resize(output_num_buffers_);
732
733 if (validity_preallocated_) {
734 ARROW_ASSIGN_OR_RAISE(out->buffers[0], kernel_ctx_->AllocateBitmap(length));
735 }
736 if (kernel_->null_handling == NullHandling::OUTPUT_NOT_NULL) {
737 out->null_count = 0;
738 }
739 for (size_t i = 0; i < data_preallocated_.size(); ++i) {
740 const auto& prealloc = data_preallocated_[i];
741 if (prealloc.bit_width >= 0) {
742 ARROW_ASSIGN_OR_RAISE(
743 out->buffers[i + 1],
744 AllocateDataBuffer(kernel_ctx_, length + prealloc.added_length,
745 prealloc.bit_width));
746 }
747 }
748 return out;
749 }
750
751 Status CheckResultType(const Datum& out, const char* function_name) override {
752 const auto& type = out.type();

Callers

nothing calls this directly

Calls 5

AllocateDataBufferFunction · 0.85
resizeMethod · 0.80
AllocateBitmapMethod · 0.80
ARROW_ASSIGN_OR_RAISEFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected