| 758 | template <typename Type> |
| 759 | struct 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 | |
| 805 | void AddKernel(Type::type type_id, std::shared_ptr<KernelSignature> signature, |
nothing calls this directly
no test coverage detected