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

Function MakeStructResolve

cpp/src/arrow/compute/kernels/scalar_nested.cc:667–699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

665 {"values"}, "StructFieldOptions", /*options_required=*/true);
666
667Result<TypeHolder> MakeStructResolve(KernelContext* ctx,
668 const std::vector<TypeHolder>& types) {
669 auto names = OptionsWrapper<MakeStructOptions>::Get(ctx).field_names;
670 auto nullable = OptionsWrapper<MakeStructOptions>::Get(ctx).field_nullability;
671 auto metadata = OptionsWrapper<MakeStructOptions>::Get(ctx).field_metadata;
672
673 if (names.size() == 0) {
674 names.resize(types.size());
675 nullable.resize(types.size(), true);
676 metadata.resize(types.size(), nullptr);
677 int i = 0;
678 for (auto& name : names) {
679 name = ToChars(i++);
680 }
681 } else if (names.size() != types.size() || nullable.size() != types.size() ||
682 metadata.size() != types.size()) {
683 return Status::Invalid("make_struct() was passed ", types.size(), " arguments but ",
684 names.size(), " field names, ", nullable.size(),
685 " nullability bits, and ", metadata.size(),
686 " metadata dictionaries.");
687 }
688
689 size_t i = 0;
690 FieldVector fields(types.size());
691
692 for (const TypeHolder& type : types) {
693 fields[i] = field(std::move(names[i]), type.GetSharedPtr(), nullable[i],
694 std::move(metadata[i]));
695 ++i;
696 }
697
698 return TypeHolder(struct_(std::move(fields)));
699}
700
701Status MakeStructExec(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) {
702 ARROW_ASSIGN_OR_RAISE(TypeHolder type, MakeStructResolve(ctx, batch.GetTypes()));

Callers

nothing calls this directly

Calls 8

ToCharsFunction · 0.85
struct_Function · 0.85
resizeMethod · 0.80
GetFunction · 0.50
InvalidFunction · 0.50
fieldFunction · 0.50
TypeHolderClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected