| 932 | } |
| 933 | |
| 934 | absl::Status EnableSelectOptimization( |
| 935 | cel::RuntimeBuilder& builder, const SelectOptimizationOptions& options) { |
| 936 | auto* flat_expr_builder = GetFlatExprBuilder(builder); |
| 937 | if (flat_expr_builder == nullptr) { |
| 938 | return absl::InvalidArgumentError( |
| 939 | "SelectOptimization requires default runtime implementation"); |
| 940 | } |
| 941 | |
| 942 | flat_expr_builder->AddAstTransform( |
| 943 | std::make_unique<SelectOptimizationAstUpdater>()); |
| 944 | // Add overloads for select optimization signature. |
| 945 | // These are never bound, only used to prevent the builder from failing on |
| 946 | // the overloads check. |
| 947 | CEL_RETURN_IF_ERROR(builder.function_registry().RegisterLazyFunction( |
| 948 | FunctionDescriptor(kCelAttribute, false, {Kind::kAny, Kind::kList}))); |
| 949 | |
| 950 | CEL_RETURN_IF_ERROR(builder.function_registry().RegisterLazyFunction( |
| 951 | FunctionDescriptor(kCelHasField, false, {Kind::kAny, Kind::kList}))); |
| 952 | // Add runtime implementation. |
| 953 | flat_expr_builder->AddProgramOptimizer( |
| 954 | CreateSelectOptimizationProgramOptimizer(options)); |
| 955 | return absl::OkStatus(); |
| 956 | } |
| 957 | |
| 958 | } // namespace cel::extensions |
no test coverage detected