scott-routledge2 commented on code in PR #48171:
URL: https://github.com/apache/arrow/pull/48171#discussion_r2556567561
##########
cpp/src/arrow/compute/kernels/scalar_cast_string.cc:
##########
@@ -304,8 +305,21 @@ BinaryToBinaryCastExec(KernelContext* ctx, const ExecSpan&
batch, ExecResult* ou
}
}
- // Start with a zero-copy cast, but change indices to expected size
- RETURN_NOT_OK(ZeroCopyCastExec(ctx, batch, out));
+ std::shared_ptr<ArrayData> input_arr = input.ToArrayData();
+ ArrayData* output = out->array_data().get();
+ output->length = input_arr->length;
+ output->SetNullCount(input_arr->null_count);
+ output->buffers = std::move(input_arr->buffers);
+ output->child_data = std::move(input_arr->child_data);
+
+ if (output->buffers[0]) {
+ // If reusing the null bitmap, ensure offset into the first byte is the
same as input.
+ output->offset = input_arr->offset % 8;
+ output->buffers[0] = SliceBuffer(output->buffers[0], input_arr->offset /
8);
+ } else {
+ output->offset = 0;
+ }
Review Comment:
Thanks for the suggestions! I didn't slice the offset buffers originally
because they are reallocated by `CastBinaryToBinaryOffsets` with the correct
offset. Although, this would only be true for the case where the offset type
changes, in the case where the offset stays the same then we would either have
to slice here or call `ZeroCopyCastExec` like in the comment above?
--
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]