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