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

Method AppendUnionScalar

cpp/src/arrow/array/builder_base.cc:196–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194 Status Visit(const DenseUnionType& type) { return MakeUnionArray(type); }
195
196 Status AppendUnionScalar(const DenseUnionType& type, const Scalar& s,
197 DenseUnionBuilder* builder) {
198 const auto& scalar = checked_cast<const DenseUnionScalar&>(s);
199 const auto scalar_field_index = type.child_ids()[scalar.type_code];
200 RETURN_NOT_OK(builder->Append(scalar.type_code));
201
202 for (int field_index = 0; field_index < type.num_fields(); ++field_index) {
203 auto* child_builder = builder->child_builder(field_index).get();
204 if (field_index == scalar_field_index) {
205 if (scalar.is_valid) {
206 RETURN_NOT_OK(child_builder->AppendScalar(*scalar.value));
207 } else {
208 RETURN_NOT_OK(child_builder->AppendNull());
209 }
210 }
211 }
212 return Status::OK();
213 }
214
215 Status AppendUnionScalar(const SparseUnionType& type, const Scalar& s,
216 SparseUnionBuilder* builder) {

Callers

nothing calls this directly

Calls 6

OKFunction · 0.50
AppendMethod · 0.45
num_fieldsMethod · 0.45
getMethod · 0.45
AppendScalarMethod · 0.45
AppendNullMethod · 0.45

Tested by

no test coverage detected