| 274 | |
| 275 | template <typename UnionBuilderType> |
| 276 | Status AppendUnionBatchInternal(const liborc::Type* type, |
| 277 | liborc::ColumnVectorBatch* column_vector_batch, |
| 278 | int64_t offset, int64_t length, ArrayBuilder* abuilder) { |
| 279 | auto builder = checked_cast<UnionBuilderType*>(abuilder); |
| 280 | auto batch = checked_cast<liborc::UnionVectorBatch*>(column_vector_batch); |
| 281 | |
| 282 | auto union_type = checked_pointer_cast<UnionType>(abuilder->type()); |
| 283 | const std::vector<int8_t>& type_codes = union_type->type_codes(); |
| 284 | const unsigned char* tags = batch->tags.data(); |
| 285 | |
| 286 | for (int64_t i = offset; i < length + offset; i++) { |
| 287 | if (!batch->hasNulls || batch->notNull[i]) { |
| 288 | auto child_id = tags[i]; |
| 289 | auto type_code = type_codes[child_id]; |
| 290 | RETURN_NOT_OK(builder->Append(type_code)); |
| 291 | |
| 292 | auto child_type = type->getSubtype(child_id); |
| 293 | auto child_batch = batch->children[child_id]; |
| 294 | auto start = static_cast<int64_t>(batch->offsets[i]); |
| 295 | RETURN_NOT_OK(AppendBatch(child_type, child_batch, start, /*length=*/1, |
| 296 | builder->child_builder(child_id).get())); |
| 297 | |
| 298 | if constexpr (std::is_same_v<UnionBuilderType, SparseUnionBuilder>) { |
| 299 | // Append null value to other child builders for sparse union type. |
| 300 | for (int8_t field_id = 0; field_id < union_type->num_fields(); field_id++) { |
| 301 | if (field_id != child_id) { |
| 302 | RETURN_NOT_OK(builder->child_builder(field_id)->AppendNull()); |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | } else { |
| 307 | RETURN_NOT_OK(builder->AppendNull()); |
| 308 | } |
| 309 | } |
| 310 | return Status::OK(); |
| 311 | } |
| 312 | |
| 313 | Status AppendUnionBatch(const liborc::Type* type, |
| 314 | liborc::ColumnVectorBatch* column_vector_batch, int64_t offset, |
nothing calls this directly
no test coverage detected