felipecrv commented on code in PR #35036:
URL: https://github.com/apache/arrow/pull/35036#discussion_r1196476398


##########
cpp/src/arrow/array/data.cc:
##########
@@ -430,8 +443,17 @@ void ArraySpan::FillFromScalar(const Scalar& value) {
     const auto& scalar = checked_cast<const RunEndEncodedScalar&>(value);
     this->child_data.resize(2);
     auto& run_end_type = scalar.run_end_type();
-    auto run_end = MakeScalar(run_end_type, 1).ValueOrDie();
-    this->child_data[0].FillFromScalar(*run_end);
+    switch (run_end_type->id()) {
+      case Type::INT16:
+        SetRunForScalar<Int16Type>(this, run_end_type, this->scratch_space);
+        break;
+      case Type::INT32:
+        SetRunForScalar<Int32Type>(this, run_end_type, this->scratch_space);
+        break;
+      default:
+        DCHECK_EQ(run_end_type->id(), Type::INT64);
+        SetRunForScalar<Int64Type>(this, run_end_type, this->scratch_space);

Review Comment:
   You're getting that stack trace you posted above from this new 
implementation?
   
   I think this will be less risky if you use the 
`this->child_data[0]->scratch_space` instead of `this->scratch_space` for the 
run-ends array buffer. I think that's the contract: an `ArraySpan` is free the 
`scratch_space` it owns directly.



-- 
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]

Reply via email to