pitrou commented on a change in pull request #8628:
URL: https://github.com/apache/arrow/pull/8628#discussion_r520724980
##########
File path: cpp/src/arrow/compute/kernels/scalar_fill_null.cc
##########
@@ -84,6 +84,52 @@ struct FillNullFunctor<Type,
enable_if_t<is_number_type<Type>::value>> {
}
};
+template <typename Type>
+struct FillNullFunctor<Type, enable_if_t<is_base_binary_type<Type>::value>> {
+ using BuilderType = typename TypeTraits<Type>::BuilderType;
+
+ static void Exec(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
+ const ArrayData& input = *batch[0].array();
+ const auto& fill_value_scalar =
+ checked_cast<const BaseBinaryScalar&>(*batch[1].scalar());
+ util::string_view fill_value =
+ static_cast<util::string_view>(*fill_value_scalar.value);
+ ArrayData* output = out->mutable_array();
+
+ // Ensure the kernel is configured properly to have no validity bitmap /
+ // null count 0 unless we explicitly propagate it below.
+ DCHECK(output->buffers[0] == nullptr);
+
+ if (input.MayHaveNulls() && fill_value_scalar.is_valid) {
+ BuilderType builder(input.type, ctx->memory_pool());
+ //
+ KERNEL_RETURN_IF_ERROR(
+ ctx, builder.ReserveData(input.buffers[2]->size() +
+ fill_value.length() *
input.GetNullCount()));
+ KERNEL_RETURN_IF_ERROR(ctx, builder.Resize(input.length + 1));
Review comment:
The +1 should not be necessary. This is the number of values appended,
not the number of offsets.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]