MCPcopy Create free account
hub / github.com/apache/arrow / ToArrayData

Method ToArrayData

cpp/src/arrow/array/data.cc:643–681  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

641int ArraySpan::num_buffers() const { return GetNumBuffers(*this->type); }
642
643std::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
683std::span<const std::shared_ptr<Buffer>> ArraySpan::GetVariadicBuffers() const {
684 DCHECK(HasVariadicBuffers());

Callers 15

ToArrayMethod · 0.95
AppendArraySliceMethod · 0.80
ToExecBatchFunction · 0.80
CastToDictionaryFunction · 0.80
ExecMethod · 0.80
MakeStructExecFunction · 0.80
IfElseGenericSXXCallFunction · 0.80
ExecVarWidthCoalesceImplFunction · 0.80
ExecArrayScalarMethod · 0.80
ExecArrayMethod · 0.80
ExecMethod · 0.80

Calls 8

num_buffersMethod · 0.95
emplace_backMethod · 0.80
storage_typeMethod · 0.80
push_backMethod · 0.80
GetBufferMethod · 0.45
idMethod · 0.45
sizeMethod · 0.45
dictionaryMethod · 0.45

Tested by

no test coverage detected