MCPcopy Create free account
hub / github.com/cel-expr/cel-go / regexExtractCostModel

Function regexExtractCostModel

ext/regex.go:404–410  ·  view source on GitHub ↗

regexExtractCostModel models regex.extract: it searches the target, and returns an optional holding the first match or capture group, a part of the target. The result is charged as the optional it is, 1 plus the size of the part (1 when nothing matched); see cost.Optional. Version 0 sizes an optiona

(id string)

Source from the content-addressed store, hash-verified

402// optional it is, 1 plus the size of the part (1 when nothing matched); see cost.Optional. Version 0
403// sizes an optional as 1, which is what v0.32.0 charged.
404func regexExtractCostModel(id string) cost.OverloadModel {
405 return cost.Overload(id,
406 cost.EvalCost(cost.Sum(cost.Const(cost.CallCost), regexSearch(cost.Arg(0), cost.Arg(1)), cost.Result())),
407 cost.ResultSize(cost.Optional(cost.AtMost(cost.Arg(0)))),
408 cost.BeforeVersion(1, cost.ManualEstimator(estimateExtractCost)),
409 )
410}
411
412// regexExtractAllCostModel models regex.extractAll: it returns parts of the target, sized as the
413// parts of a split.

Callers 1

CompileOptionsMethod · 0.85

Calls 12

OverloadFunction · 0.92
EvalCostFunction · 0.92
SumFunction · 0.92
ConstFunction · 0.92
ArgFunction · 0.92
ResultFunction · 0.92
ResultSizeFunction · 0.92
OptionalFunction · 0.92
AtMostFunction · 0.92
BeforeVersionFunction · 0.92
ManualEstimatorFunction · 0.92
regexSearchFunction · 0.85

Tested by

no test coverage detected