Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update SelectOptimization and AttributeTracking to behave consistently with cel.bind. #524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion eval/eval/ident_step.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ absl::Status SlotStep::Evaluate(ExecutionFrame* frame) const {

if (frame->enable_missing_attribute_errors() &&
frame->attribute_utility().CheckForMissingAttribute(attribute_trail)) {
CEL_ASSIGN_OR_RETURN(std::string attribute,
attribute_trail.attribute().AsString());
frame->value_stack().Push(frame->value_factory().CreateErrorValue(
CreateMissingAttributeError(name_)));
CreateMissingAttributeError(std::move(attribute))));
return absl::OkStatus();
}

Expand Down
14 changes: 12 additions & 2 deletions eval/public/cel_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ struct InterpreterOptions {
//
// Note: In most cases enabling this option is safe, however to perform this
// optimization overloads are not consulted for applicable calls. If you have
// overriden the default `matches` function you should not enable this option.
// overridden the default `matches` function you should not enable this
// option.
bool enable_regex_precompilation = false;

// Enable select optimization, replacing long select chains with a single
Expand All @@ -158,7 +159,16 @@ struct InterpreterOptions {
// enabling in an existing environment.
bool enable_select_optimization = false;

// TODO(uncreated-issue/63): Do not use -- implementation in progress.
// Enable lazy cel.bind alias initialization.
//
// When enabled, cel.bind definition subexpression will be evaluated when the
// evaluator first requires the alias in the subexpression using the bound
// alias. When disabled, the cel.bind definition is eagerly evaluated.
//
// This prevents eagerly evaluating the definition subexpression if it is
// never used in the result subexpression of the cel.bind() macro. This allows
// for consistent behavior for CEL compiler optimized expressions that extract
// subexpressions to cel.bind calls.
bool enable_lazy_bind_initialization = false;
};
// LINT.ThenChange(//depot/google3/runtime/runtime_options.h)
Expand Down
8 changes: 7 additions & 1 deletion extensions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,22 @@ cc_test(
srcs = ["bindings_ext_test.cc"],
deps = [
":bindings_ext",
"//base:attributes",
"//eval/public:activation",
"//eval/public:builtin_func_registrar",
"//eval/public:cel_expr_builder_factory",
"//eval/public:cel_expression",
"//eval/public:cel_function",
"//eval/public:cel_function_adapter",
"//eval/public:cel_options",
"//eval/public:cel_value",
"//eval/public/structs:cel_proto_wrapper",
"//internal:testing",
"//parser",
"@com_google_absl//absl/strings:string_view",
"@com_google_cel_spec//proto/test/v1/proto2:test_all_types_cc_proto",
"@com_google_googleapis//google/api/expr/v1alpha1:syntax_cc_proto",
"@com_google_protobuf//:protobuf",
],
)

Expand Down Expand Up @@ -192,7 +199,6 @@ cc_library(
"//runtime:runtime_options",
"//runtime/internal:errors",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/status",
Expand Down
Loading