| 605 | } |
| 606 | |
| 607 | static std::shared_ptr<Array> MakeStructArray(::arrow::random::RandomArrayGenerator* rng, |
| 608 | const ArrayVector& children, |
| 609 | double null_probability, |
| 610 | bool propagate_validity = false) { |
| 611 | ARROW_CHECK_GT(children.size(), 0); |
| 612 | const int64_t length = children[0]->length(); |
| 613 | |
| 614 | std::shared_ptr<::arrow::Buffer> null_bitmap; |
| 615 | if (null_probability > 0.0) { |
| 616 | null_bitmap = rng->NullBitmap(length, null_probability); |
| 617 | if (propagate_validity) { |
| 618 | // HACK: the Parquet writer currently doesn't allow non-empty list |
| 619 | // entries where a parent node is null (for instance, a struct-of-list |
| 620 | // where the outer struct is marked null but the inner list value is |
| 621 | // non-empty). |
| 622 | for (const auto& child : children) { |
| 623 | null_bitmap = *::arrow::internal::BitmapOr( |
| 624 | ::arrow::default_memory_pool(), null_bitmap->data(), 0, |
| 625 | child->null_bitmap_data(), 0, length, 0); |
| 626 | } |
| 627 | } |
| 628 | } |
| 629 | FieldVector fields(children.size()); |
| 630 | char field_name = 'a'; |
| 631 | for (size_t i = 0; i < children.size(); ++i) { |
| 632 | fields[i] = field(std::string{field_name++}, children[i]->type(), |
| 633 | /*nullable=*/null_probability > 0.0); |
| 634 | } |
| 635 | return *::arrow::StructArray::Make(children, std::move(fields), null_bitmap); |
| 636 | } |
| 637 | |
| 638 | // Make a (int32, int64) struct array |
| 639 | static std::shared_ptr<Array> MakeStructArray(::arrow::random::RandomArrayGenerator* rng, |
no test coverage detected