| 571 | |
| 572 | struct ArrayExportChecker { |
| 573 | void operator()(struct ArrowArray* c_export, const ArrayData& expected_data) { |
| 574 | ASSERT_EQ(c_export->length, expected_data.length); |
| 575 | ASSERT_EQ(c_export->null_count, expected_data.null_count); |
| 576 | ASSERT_EQ(c_export->offset, expected_data.offset); |
| 577 | |
| 578 | const DataType* physical_type = expected_data.type.get(); |
| 579 | if (physical_type->id() == Type::EXTENSION) { |
| 580 | physical_type = |
| 581 | checked_cast<const ExtensionType&>(*physical_type).storage_type().get(); |
| 582 | } |
| 583 | |
| 584 | auto expected_n_buffers = static_cast<int64_t>(expected_data.buffers.size()); |
| 585 | auto expected_buffers = expected_data.buffers.data(); |
| 586 | if (!internal::may_have_validity_bitmap(physical_type->id())) { |
| 587 | --expected_n_buffers; |
| 588 | ++expected_buffers; |
| 589 | } |
| 590 | |
| 591 | bool has_variadic_buffer_sizes = |
| 592 | expected_data.type->storage_id() == Type::BINARY_VIEW || |
| 593 | expected_data.type->storage_id() == Type::STRING_VIEW; |
| 594 | ASSERT_EQ(c_export->n_buffers, expected_n_buffers + has_variadic_buffer_sizes); |
| 595 | ASSERT_NE(c_export->buffers, nullptr); |
| 596 | |
| 597 | for (int64_t i = 0; i < expected_n_buffers; ++i) { |
| 598 | auto expected_ptr = expected_buffers[i] ? expected_buffers[i]->data() : nullptr; |
| 599 | ASSERT_EQ(c_export->buffers[i], expected_ptr); |
| 600 | } |
| 601 | if (has_variadic_buffer_sizes) { |
| 602 | auto variadic_buffers = std::span(expected_data.buffers).subspan(2); |
| 603 | auto variadic_buffer_sizes = std::span( |
| 604 | static_cast<const int64_t*>(c_export->buffers[c_export->n_buffers - 1]), |
| 605 | variadic_buffers.size()); |
| 606 | for (auto [buf, size] : Zip(variadic_buffers, variadic_buffer_sizes)) { |
| 607 | ASSERT_EQ(buf->size(), size); |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | if (expected_data.dictionary != nullptr) { |
| 612 | // Recurse into dictionary |
| 613 | ASSERT_NE(c_export->dictionary, nullptr); |
| 614 | operator()(c_export->dictionary, *expected_data.dictionary); |
| 615 | } else { |
| 616 | ASSERT_EQ(c_export->dictionary, nullptr); |
| 617 | } |
| 618 | |
| 619 | ASSERT_EQ(c_export->n_children, |
| 620 | static_cast<int64_t>(expected_data.child_data.size())); |
| 621 | if (c_export->n_children > 0) { |
| 622 | ASSERT_NE(c_export->children, nullptr); |
| 623 | // Recurse into children |
| 624 | for (int64_t i = 0; i < c_export->n_children; ++i) { |
| 625 | ASSERT_NE(c_export->children[i], nullptr); |
| 626 | operator()(c_export->children[i], *expected_data.child_data[i]); |
| 627 | } |
| 628 | } else { |
| 629 | ASSERT_EQ(c_export->children, nullptr); |
| 630 | } |
nothing calls this directly
no test coverage detected