| 817 | |
| 818 | template <typename ArrayType, typename RAG> |
| 819 | Result<std::shared_ptr<Array>> ArrayOfListView(RAG& self, const Field& field, |
| 820 | int64_t length, int64_t alignment, |
| 821 | MemoryPool* memory_pool, |
| 822 | double null_probability) { |
| 823 | using TypeClass = typename ArrayType::TypeClass; |
| 824 | using offset_type = typename ArrayType::offset_type; |
| 825 | using OffsetArrayType = typename CTypeTraits<offset_type>::ArrayType; |
| 826 | using OffsetArrowType = typename CTypeTraits<offset_type>::ArrowType; |
| 827 | |
| 828 | const auto min_length = |
| 829 | GetMetadata<offset_type>(field.metadata().get(), "min_length", 0); |
| 830 | const auto max_length = |
| 831 | GetMetadata<offset_type>(field.metadata().get(), "max_length", 20); |
| 832 | const auto force_empty_nulls = |
| 833 | GetMetadata<bool>(field.metadata().get(), "force_empty_nulls", false); |
| 834 | const auto zero_undefined_offsets = |
| 835 | GetMetadata<bool>(field.metadata().get(), "zero_undefined_offsets", false); |
| 836 | const auto lengths = internal::checked_pointer_cast<OffsetArrayType>( |
| 837 | self.RAG::template Numeric<OffsetArrowType, offset_type>( |
| 838 | length, min_length, max_length, null_probability)); |
| 839 | |
| 840 | int64_t max_view_end = 0; |
| 841 | const auto offsets = ViewOffsetsFromLengthsArray<OffsetArrayType, offset_type>( |
| 842 | self.seed(), *lengths, force_empty_nulls, zero_undefined_offsets, &max_view_end, |
| 843 | alignment, memory_pool); |
| 844 | |
| 845 | const auto values = self.RAG::ArrayOf( |
| 846 | *internal::checked_pointer_cast<TypeClass>(field.type())->value_field(), |
| 847 | /*values_length=*/max_view_end, alignment, memory_pool); |
| 848 | |
| 849 | ARROW_ASSIGN_OR_RAISE(auto list_view_array, |
| 850 | ArrayType::FromArrays(field.type(), *offsets, *lengths, *values)); |
| 851 | ShuffleListViewDataInPlace<TypeClass>( |
| 852 | self.seed(), const_cast<ArrayData*>(list_view_array->data().get())); |
| 853 | return list_view_array; |
| 854 | } |
| 855 | |
| 856 | template <typename ArrayType, typename RAG> |
| 857 | Result<std::shared_ptr<Array>> RandomListView(RAG& self, const Array& values, |