kszucs commented on a change in pull request #7684:
URL: https://github.com/apache/arrow/pull/7684#discussion_r453648012
##########
File path: cpp/src/arrow/array/util.cc
##########
@@ -323,15 +336,52 @@ class RepeatedArrayFactory {
return Status::OK();
}
- Status Visit(const FixedSizeBinaryType&) {
- std::shared_ptr<Buffer> value =
- checked_cast<const FixedSizeBinaryScalar&>(scalar_).value;
- return FinishFixedWidth(value->data(), value->size());
+ template <typename T>
+ enable_if_var_size_list<T, Status> Visit(const T& type) {
+ using ScalarType = typename TypeTraits<T>::ScalarType;
+ using ArrayType = typename TypeTraits<T>::ArrayType;
+
+ auto value = checked_cast<const ScalarType&>(scalar_).value;
+
+ ArrayVector values(length_, value);
+ ARROW_ASSIGN_OR_RAISE(auto value_array, Concatenate(values, pool_));
+
+ std::shared_ptr<Buffer> offsets_buffer;
+ auto size = static_cast<typename T::offset_type>(value->length());
+ RETURN_NOT_OK(CreateOffsetsBuffer(size, &offsets_buffer));
+
+ out_ =
+ std::make_shared<ArrayType>(scalar_.type, length_, offsets_buffer,
value_array);
+ return Status::OK();
}
- Status Visit(const Decimal128Type&) {
- auto value = checked_cast<const
Decimal128Scalar&>(scalar_).value.ToBytes();
- return FinishFixedWidth(value.data(), value.size());
+ Status Visit(const FixedSizeListType& type) {
+ auto value = checked_cast<const FixedSizeListScalar&>(scalar_).value;
+
+ ArrayVector values(length_, value);
+ ARROW_ASSIGN_OR_RAISE(auto value_array, Concatenate(values, pool_));
+
+ out_ = std::make_shared<FixedSizeListArray>(scalar_.type, length_,
value_array);
+ return Status::OK();
+ }
+
+ Status Visit(const MapType& type) {
+ auto map_scalar = checked_cast<const MapScalar&>(scalar_);
+ auto struct_array = checked_cast<const
StructArray*>(map_scalar.value.get());
+
+ ArrayVector keys(length_, struct_array->field(0));
+ ArrayVector values(length_, struct_array->field(1));
+
+ ARROW_ASSIGN_OR_RAISE(auto key_array, Concatenate(keys, pool_));
Review comment:
We may want to add a more efficient implementations later.
----------------------------------------------------------------
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]