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