felipecrv commented on code in PR #35036:
URL: https://github.com/apache/arrow/pull/35036#discussion_r1196477996
##########
cpp/src/arrow/array/data.cc:
##########
@@ -236,6 +236,19 @@ void SetOffsetsForScalar(ArraySpan* span, offset_type*
buffer, int64_t value_siz
span->buffers[buffer_index].size = 2 * sizeof(offset_type);
}
+template <typename ArrowType>
+void SetRunForScalar(ArraySpan* span, std::shared_ptr<DataType> type,
+ uint64_t* scratch_space) {
+ // Create a lenght-1 array with the value 1 for a REE scalar
+ using run_type = typename ArrowType::c_type;
+ auto buffer = reinterpret_cast<run_type*>(scratch_space);
+ buffer[0] = static_cast<run_type>(1);
+ auto data_buffer =
+ std::make_shared<Buffer>(reinterpret_cast<uint8_t*>(buffer),
sizeof(run_type));
+ auto data = ArrayData::Make(type, 1, {nullptr, data_buffer}, 0);
+ span->child_data[0].SetMembers(*data);
Review Comment:
You could derive the `scratch_space` parameter from that as well: making you
use the `child_data[0].scratch_space` instead of the parent's `scratch_space`.
--
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]