| 120 | } |
| 121 | |
| 122 | int8_t BasicUnionBuilder::NextTypeId() { |
| 123 | // Find type_id such that type_id_to_children_[type_id] == nullptr |
| 124 | // and use that for the new child. Start searching at dense_type_id_ |
| 125 | // since type_id_to_children_ is densely packed up at least up to dense_type_id_ |
| 126 | for (; static_cast<size_t>(dense_type_id_) < type_id_to_children_.size(); |
| 127 | ++dense_type_id_) { |
| 128 | if (type_id_to_children_[dense_type_id_] == nullptr) { |
| 129 | return dense_type_id_++; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | DCHECK_LT( |
| 134 | type_id_to_children_.size(), |
| 135 | static_cast<decltype(type_id_to_children_)::size_type>(UnionType::kMaxTypeCode)); |
| 136 | |
| 137 | // type_id_to_children_ is already densely packed, so just append the new child |
| 138 | type_id_to_child_id_.resize(type_id_to_child_id_.size() + 1); |
| 139 | type_id_to_children_.resize(type_id_to_children_.size() + 1); |
| 140 | return dense_type_id_++; |
| 141 | } |
| 142 | |
| 143 | Status SparseUnionBuilder::AppendArraySlice(const ArraySpan& array, const int64_t offset, |
| 144 | const int64_t length) { |