| 641 | int ArraySpan::num_buffers() const { return GetNumBuffers(*this->type); } |
| 642 | |
| 643 | std::shared_ptr<ArrayData> ArraySpan::ToArrayData() const { |
| 644 | auto result = std::make_shared<ArrayData>(this->type->GetSharedPtr(), this->length, |
| 645 | this->null_count, this->offset); |
| 646 | |
| 647 | for (int i = 0; i < this->num_buffers(); ++i) { |
| 648 | result->buffers.emplace_back(this->GetBuffer(i)); |
| 649 | } |
| 650 | |
| 651 | Type::type type_id = this->type->id(); |
| 652 | if (type_id == Type::EXTENSION) { |
| 653 | const ExtensionType* ext_type = checked_cast<const ExtensionType*>(this->type); |
| 654 | type_id = ext_type->storage_type()->id(); |
| 655 | } |
| 656 | |
| 657 | if (HasVariadicBuffers()) { |
| 658 | DCHECK_EQ(result->buffers.size(), 3); |
| 659 | result->buffers.pop_back(); |
| 660 | for (const auto& data_buffer : GetVariadicBuffers()) { |
| 661 | result->buffers.push_back(data_buffer); |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | if (type_id == Type::NA) { |
| 666 | result->null_count = this->length; |
| 667 | } else if (this->buffers[0].data == nullptr) { |
| 668 | // No validity bitmap, so the null count is 0 |
| 669 | result->null_count = 0; |
| 670 | } |
| 671 | |
| 672 | if (type_id == Type::DICTIONARY) { |
| 673 | result->dictionary = this->dictionary().ToArrayData(); |
| 674 | } else { |
| 675 | // Emit children, too |
| 676 | for (size_t i = 0; i < this->child_data.size(); ++i) { |
| 677 | result->child_data.push_back(this->child_data[i].ToArrayData()); |
| 678 | } |
| 679 | } |
| 680 | return result; |
| 681 | } |
| 682 | |
| 683 | std::span<const std::shared_ptr<Buffer>> ArraySpan::GetVariadicBuffers() const { |
| 684 | DCHECK(HasVariadicBuffers()); |
no test coverage detected