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

Function AppendUnionBatchInternal

cpp/src/arrow/adapters/orc/util.cc:276–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274
275template <typename UnionBuilderType>
276Status 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
313Status AppendUnionBatch(const liborc::Type* type,
314 liborc::ColumnVectorBatch* column_vector_batch, int64_t offset,

Callers

nothing calls this directly

Calls 8

AppendBatchFunction · 0.85
OKFunction · 0.50
typeMethod · 0.45
dataMethod · 0.45
AppendMethod · 0.45
getMethod · 0.45
num_fieldsMethod · 0.45
AppendNullMethod · 0.45

Tested by

no test coverage detected