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

Method Exec

cpp/src/arrow/compute/kernels/vector_replace.cc:760–802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

758template <typename Type>
759struct FillNullBackwardChunked {
760 static Status Exec(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
761 DCHECK_EQ(Datum::CHUNKED_ARRAY, batch[0].kind());
762 const ChunkedArray& values = *batch[0].chunked_array();
763 if (values.null_count() == 0) {
764 *out = Datum(values);
765 return Status::OK();
766 }
767 if (values.null_count() == values.length()) {
768 *out = Datum(values);
769 return Status::OK();
770 }
771 std::vector<std::shared_ptr<Array>> new_chunks;
772
773 if (values.length() > 0) {
774 auto chunks_length = static_cast<int>(values.chunks().size());
775 ArrayData* array_with_current =
776 values.chunk(/*first_chunk=*/chunks_length - 1)->data().get();
777 int64_t last_valid_value_offset = -1;
778 auto chunks = values.chunks();
779 for (int i = chunks_length - 1; i >= 0; --i) {
780 const auto& chunk = chunks[i];
781 if (is_fixed_width(out->type()->id())) {
782 ArrayData* output = out->mutable_array();
783 auto data_bytes = output->type->byte_width() * chunk->length();
784 ARROW_ASSIGN_OR_RAISE(output->buffers[0], ctx->AllocateBitmap(chunk->length()));
785 ARROW_ASSIGN_OR_RAISE(output->buffers[1], ctx->Allocate(data_bytes));
786 }
787 ExecResult chunk_result;
788 chunk_result.value = out->array();
789 RETURN_NOT_OK(FillNullBackward<Type>::ExecChunk(
790 ctx, *chunk->data(), &chunk_result, *array_with_current,
791 &last_valid_value_offset));
792 if (chunk->null_count() != chunk->length()) {
793 array_with_current = chunk->data().get();
794 }
795 new_chunks.push_back(MakeArray(chunk_result.array_data()->Copy()));
796 }
797 }
798
799 std::reverse(new_chunks.begin(), new_chunks.end());
800 *out = std::make_shared<ChunkedArray>(std::move(new_chunks), values.type());
801 return Status::OK();
802 }
803};
804
805void AddKernel(Type::type type_id, std::shared_ptr<KernelSignature> signature,

Callers

nothing calls this directly

Calls 15

is_fixed_widthFunction · 0.85
chunked_arrayMethod · 0.80
AllocateBitmapMethod · 0.80
push_backMethod · 0.80
array_dataMethod · 0.80
MakeArrayFunction · 0.70
DatumClass · 0.50
OKFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
kindMethod · 0.45
null_countMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected