kiszk commented on a change in pull request #7507:
URL: https://github.com/apache/arrow/pull/7507#discussion_r472905861
##########
File path: cpp/src/arrow/array/util.cc
##########
@@ -74,6 +74,177 @@ class ArrayDataWrapper {
std::shared_ptr<Array>* out_;
};
+class ArrayDataEndianSwapper {
+ public:
+ ArrayDataEndianSwapper(std::shared_ptr<ArrayData>& data, int64_t length)
+ : data_(data), length_(length) {}
+
+ Status SwapType(const DataType& type) { return VisitTypeInline(type, this); }
+
+ Status SwapChildren(std::vector<std::shared_ptr<Field>> child_fields) {
+ int i = 0;
+ for (const auto& child_field : child_fields) {
+ auto orig_data = data_;
+ auto orig_length = length_;
+ data_ = data_->child_data[i++];
+ length_ = data_->length;
+ RETURN_NOT_OK(SwapType(*child_field.get()->type()));
+ length_ = orig_length;
+ data_ = orig_data;
+ }
+ return Status::OK();
+ }
+
+ template <typename VALUE_TYPE>
+ Status SwapOffset(int index) {
+ if (data_->buffers[index] == nullptr) {
+ return Status::OK();
+ }
+ auto buffer = const_cast<VALUE_TYPE*>(
Review comment:
@pitrou Since I was swamped with something in my company, I was late to
address this. Now, I updated the code to reallocate the buffer. Could you
please look at this again?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]