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

Method FromValue

cpp/src/arrow/scalar.cc:853–867  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

851}
852
853std::shared_ptr<Scalar> SparseUnionScalar::FromValue(std::shared_ptr<Scalar> value,
854 int field_index,
855 std::shared_ptr<DataType> type) {
856 const auto& union_type = checked_cast<const SparseUnionType&>(*type);
857 int8_t type_code = union_type.type_codes()[field_index];
858 ScalarVector field_values;
859 for (int i = 0; i < type->num_fields(); ++i) {
860 if (i == field_index) {
861 field_values.emplace_back(std::move(value));
862 } else {
863 field_values.emplace_back(MakeNullScalar(type->field(i)->type()));
864 }
865 }
866 return std::make_shared<SparseUnionScalar>(field_values, type_code, std::move(type));
867}
868
869void SparseUnionScalar::FillScratchSpace(uint8_t* scratch_space, int8_t type_code) {
870 auto* union_scratch_space = reinterpret_cast<UnionScratchSpace*>(scratch_space);

Callers

nothing calls this directly

Calls 5

MakeNullScalarFunction · 0.85
emplace_backMethod · 0.80
num_fieldsMethod · 0.45
typeMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected