kou commented on PR #48128:
URL: https://github.com/apache/arrow/pull/48128#issuecomment-3536202432

   Can we simplify this something like the following?
   
   ```diff
   diff --git a/cpp/src/arrow/array/array_nested.cc 
b/cpp/src/arrow/array/array_nested.cc
   index b821451419..4eb5e82087 100644
   --- a/cpp/src/arrow/array/array_nested.cc
   +++ b/cpp/src/arrow/array/array_nested.cc
   @@ -1086,8 +1086,10 @@ const std::shared_ptr<Array>& StructArray::field(int 
i) const {
          field_data = data_->child_data[i];
        }
        result = MakeArray(field_data);
   -    std::atomic_store(&boxed_fields_[i], std::move(result));
   -    return boxed_fields_[i];
   +    // If some other thread inserted the array in the meantime, just
   +    // drop this array.
   +    std::shared_ptr<Array> expected = nullptr;
   +    std::atomic_compare_exchange_weak(&boxed_fields_[i], &expected, 
std::move(result));
      }
      return boxed_fields_[i];
    }
   ```


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