edponce commented on a change in pull request #11023:
URL: https://github.com/apache/arrow/pull/11023#discussion_r739522336
##########
File path: cpp/src/arrow/compute/kernels/scalar_string.cc
##########
@@ -402,16 +401,16 @@ struct StringTransformExecBase {
if (!input.is_valid) {
return Status::OK();
}
- auto* result = checked_cast<BaseBinaryScalar*>(out->scalar().get());
- result->is_valid = true;
const int64_t data_nbytes = static_cast<int64_t>(input.value->size());
-
const int64_t output_ncodeunits_max = transform->MaxCodeunits(1,
data_nbytes);
if (output_ncodeunits_max > std::numeric_limits<offset_type>::max()) {
return Status::CapacityError(
"Result might not fit in a 32bit utf8 array, convert to large_utf8");
}
+
ARROW_ASSIGN_OR_RAISE(auto value_buffer,
ctx->Allocate(output_ncodeunits_max));
+ auto* result = checked_cast<BaseBinaryScalar*>(out->scalar().get());
Review comment:
This is a very good observation. A simple search through the C++
codebase shows that both patterns are used. I agree with having `nullptr`
checks after `checked_cast<...*>()`. I will ask the in Zulip dev to see if this
is a pattern we want to enforce. If so, then we should create JIRA.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]