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

Function ApplyQualifier

extensions/select_optimization.cc:270–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270absl::StatusOr<Value> ApplyQualifier(
271 const Value& operand, const SelectQualifier& qualifier,
272 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
273 google::protobuf::MessageFactory* absl_nonnull message_factory,
274 google::protobuf::Arena* absl_nonnull arena) {
275 return absl::visit(
276 absl::Overload(
277 [&](const FieldSpecifier& field_specifier) -> absl::StatusOr<Value> {
278 if (!operand.Is<StructValue>()) {
279 return cel::ErrorValue(
280 cel::runtime_internal::CreateNoMatchingOverloadError(
281 "<select>"));
282 }
283 return operand.GetStruct().GetFieldByName(
284 field_specifier.name, descriptor_pool, message_factory, arena);
285 },
286 [&](const AttributeQualifier& qualifier) -> absl::StatusOr<Value> {
287 if (operand.Is<ListValue>()) {
288 auto index_or = ListIndexFromQualifier(qualifier);
289 if (!index_or.ok()) {
290 return cel::ErrorValue(index_or.status());
291 }
292 return operand.GetList().Get(*index_or, descriptor_pool,
293 message_factory, arena);
294 } else if (operand.Is<MapValue>()) {
295 auto key_or = MapKeyFromQualifier(qualifier, arena);
296 if (!key_or.ok()) {
297 return cel::ErrorValue(key_or.status());
298 }
299 return operand.GetMap().Get(*key_or, descriptor_pool,
300 message_factory, arena);
301 }
302 return cel::ErrorValue(
303 cel::runtime_internal::CreateNoMatchingOverloadError(
304 cel::builtin::kIndex));
305 }),
306 qualifier);
307}
308
309absl::StatusOr<Value> FallbackSelect(
310 const Value& root, absl::Span<const SelectQualifier> select_path,

Callers 1

FallbackSelectFunction · 0.85

Calls 10

ErrorValueFunction · 0.85
ListIndexFromQualifierFunction · 0.85
MapKeyFromQualifierFunction · 0.85
GetFieldByNameMethod · 0.45
GetStructMethod · 0.45
okMethod · 0.45
GetMethod · 0.45
GetListMethod · 0.45
GetMapMethod · 0.45

Tested by

no test coverage detected