MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / MergeUnknowns

Method MergeUnknowns

eval/eval/attribute_utility.cc:107–131  ·  view source on GitHub ↗

Creates merged UnknownAttributeSet. Scans over the args collection, merges any UnknownSets found in it together with initial_set (if initial_set is not null). Returns pointer to merged set or nullptr, if there were no sets to merge.

Source from the content-addressed store, hash-verified

105// it together with initial_set (if initial_set is not null).
106// Returns pointer to merged set or nullptr, if there were no sets to merge.
107absl::optional<UnknownValue> AttributeUtility::MergeUnknowns(
108 absl::Span<const cel::Value> args) const {
109 // Empty unknown value may be used as a sentinel in some tests so need to
110 // distinguish unset (nullopt) and empty(engaged empty value).
111 absl::optional<UnknownSet> result_set;
112
113 for (const auto& value : args) {
114 if (!value->Is<cel::UnknownValue>()) continue;
115 if (!result_set.has_value()) {
116 result_set.emplace();
117 }
118 const auto& current_set = value.GetUnknown();
119
120 cel::base_internal::UnknownSetAccess::Add(
121 *result_set, UnknownSet(current_set.attribute_set(),
122 current_set.function_result_set()));
123 }
124
125 if (!result_set.has_value()) {
126 return absl::nullopt;
127 }
128
129 return UnknownValue(cel::Unknown(result_set->unknown_attributes(),
130 result_set->unknown_function_results()));
131}
132
133UnknownValue AttributeUtility::MergeUnknownValues(
134 const UnknownValue& left, const UnknownValue& right) const {

Callers 3

TEST_FFunction · 0.80
CalculateMethod · 0.80
NoOverloadResultFunction · 0.80

Calls 4

UnknownSetClass · 0.50
UnknownValueClass · 0.50
has_valueMethod · 0.45
GetUnknownMethod · 0.45

Tested by 1

TEST_FFunction · 0.64