| 46 | } |
| 47 | |
| 48 | Status DenseUnionBuilder::AppendArraySlice(const ArraySpan& array, const int64_t offset, |
| 49 | const int64_t length) { |
| 50 | const int8_t* type_codes = array.GetValues<int8_t>(1); |
| 51 | const int32_t* offsets = array.GetValues<int32_t>(2); |
| 52 | for (int64_t row = offset; row < offset + length; row++) { |
| 53 | const int8_t type_code = type_codes[row]; |
| 54 | const int child_id = type_id_to_child_id_[type_code]; |
| 55 | const int32_t union_offset = offsets[row]; |
| 56 | RETURN_NOT_OK(Append(type_code)); |
| 57 | RETURN_NOT_OK(type_id_to_children_[type_code]->AppendArraySlice( |
| 58 | array.child_data[child_id], union_offset, /*length=*/1)); |
| 59 | } |
| 60 | return Status::OK(); |
| 61 | } |
| 62 | |
| 63 | Status DenseUnionBuilder::FinishInternal(std::shared_ptr<ArrayData>* out) { |
| 64 | ARROW_RETURN_NOT_OK(BasicUnionBuilder::FinishInternal(out)); |