// Sets returns a cel.EnvOption to configure namespaced set relationship // functions. // // There is no set type within CEL, and while one may be introduced in the // future, there are cases where a `list` type is known to behave like a set. // For such cases, this library provides some basic functionality for // determining set containment, equivalence, and intersection. // // # Sets.Contains // // Returns whether the first list argument contains all elements in the second // list argument. The list may contain elements of any type and standard CEL // equality is used to determine whether a value exists in both lists. If the // second list is empty, the result will always return true. // // sets.contains(list(T), list(T)) -> bool // // Examples: // // sets.contains([], []) // true // sets.contains([], [1]) // false // sets.contains([1, 2, 3, 4], [2, 3]) // true // sets.contains([1, 2.0, 3u], [1.0, 2u, 3]) // true // // # Sets.Equivalent // // Returns whether the first and second list are set equivalent. Lists are set // equivalent if for every item in the first list, there is an element in the // second which is equal. The lists may not be of the same size as they do not // guarantee the elements within them are unique, so size does not factor into // the computation. // // Examples: // // sets.equivalent([], []) // true // sets.equivalent([1], [1, 1]) // true // sets.equivalent([1], [1u, 1.0]) // true // sets.equivalent([1, 2, 3], [3u, 2.0, 1]) // true // // # Sets.Intersects // // Returns whether the first list has at least one element whose value is equal // to an element in the second list. If either list is empty, the result will // be false. // // Examples: // // sets.intersects([1], []) // false // sets.intersects([1], [1, 2]) // true // sets.intersects([[1], [2, 3]], [[1, 2], [2, 3.0]]) // true func Sets() cel.EnvOption { … } type setsLib … // LibraryName implements the SingletonLibrary interface method. func (setsLib) LibraryName() string { … } // CompileOptions implements the Library interface method. func (setsLib) CompileOptions() []cel.EnvOption { … } // ProgramOptions implements the Library interface method. func (setsLib) ProgramOptions() []cel.ProgramOption { … } // NewSetMembershipOptimizer rewrites set membership tests using the `in` operator against a list // of constant values of enum, int, uint, string, or boolean type into a set membership test against // a map where the map keys are the elements of the list. func NewSetMembershipOptimizer() (cel.ASTOptimizer, error) { … } func (setsLib) Optimize(ctx *cel.OptimizerContext, a *ast.AST) *ast.AST { … } func matchInConstantList(a *ast.AST) ast.ExprMatcher { … } func setsIntersects(listA, listB ref.Val) ref.Val { … } func setsContains(list, sublist ref.Val) ref.Val { … } func setsEquivalent(listA, listB ref.Val) ref.Val { … } func estimateSetsCost(costFactor float64) checker.FunctionEstimator { … } func estimateSize(estimator checker.CostEstimator, node checker.AstNode) checker.SizeEstimate { … } func trackSetsCost(costFactor float64) interpreter.FunctionTracker { … } func actualSize(value ref.Val) uint64 { … } var callCostEstimate … var callCost …