jorisvandenbossche commented on code in PR #35036:
URL: https://github.com/apache/arrow/pull/35036#discussion_r1201756681
##########
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:
The same is done for Dictionary though:
```
// Populate dictionary data
const auto& dict_scalar = checked_cast<const DictionaryScalar&>(value);
this->child_data.resize(1);
this->child_data[0].SetMembers(*dict_scalar.value.dictionary->data());
```
https://github.com/apache/arrow/blob/fbe5f641d327ee81db00ce5f056940a69f4d8603/cpp/src/arrow/array/data.cc#L325C1-L328
Or is that fine because that is data owned by the scalar?
--
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]