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

Method ProcessUnion

cpp/src/arrow/c/bridge.cc:1355–1389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1353 }
1354
1355 Status ProcessUnion() {
1356 RETURN_NOT_OK(f_parser_.CheckHasNext());
1357 UnionMode::type mode;
1358 switch (f_parser_.Next()) {
1359 case 'd':
1360 mode = UnionMode::DENSE;
1361 break;
1362 case 's':
1363 mode = UnionMode::SPARSE;
1364 break;
1365 default:
1366 return f_parser_.Invalid();
1367 }
1368 RETURN_NOT_OK(f_parser_.CheckNext(':'));
1369 ARROW_ASSIGN_OR_RAISE(auto type_codes, f_parser_.ParseInts<int8_t>(f_parser_.Rest()));
1370 ARROW_ASSIGN_OR_RAISE(auto fields, MakeChildFields());
1371 if (fields.size() != type_codes.size()) {
1372 return Status::Invalid(
1373 "ArrowArray struct number of children incompatible with format string "
1374 "(mismatching number of union type codes) ",
1375 "'", c_struct_->format, "'");
1376 }
1377 for (const auto code : type_codes) {
1378 if (code < 0) {
1379 return Status::Invalid("Negative type code in union: format string '",
1380 c_struct_->format, "'");
1381 }
1382 }
1383 if (mode == UnionMode::SPARSE) {
1384 type_ = sparse_union(std::move(fields), std::move(type_codes));
1385 } else {
1386 type_ = dense_union(std::move(fields), std::move(type_codes));
1387 }
1388 return Status::OK();
1389 }
1390
1391 Status ProcessREE() {
1392 RETURN_NOT_OK(f_parser_.CheckAtEnd());

Callers

nothing calls this directly

Calls 9

sparse_unionFunction · 0.85
dense_unionFunction · 0.85
CheckHasNextMethod · 0.80
InvalidMethod · 0.80
CheckNextMethod · 0.80
InvalidFunction · 0.50
OKFunction · 0.50
NextMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected