felipecrv commented on code in PR #35036: URL: https://github.com/apache/arrow/pull/35036#discussion_r1202412529
########## cpp/src/arrow/array/data.cc: ########## @@ -236,17 +236,16 @@ 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); +template <typename RunEndType> +void FillRunEndsArrayForScalar(ArraySpan* span, std::shared_ptr<DataType> run_end_type) { + using RunEndCType = typename RunEndType::c_type; + auto buffer = reinterpret_cast<RunEndCType*>(span->scratch_space); + buffer[0] = static_cast<RunEndCType>(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); + std::make_shared<Buffer>(reinterpret_cast<uint8_t*>(buffer), sizeof(RunEndCType)); + auto data = + ArrayData::Make(std::move(run_end_type), 1, {nullptr, std::move(data_buffer)}, 0); + span->SetMembers(*data); Review Comment: > Or is that fine because that is data owned by the scalar? Yes. -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org