MCPcopy Create free account
hub / github.com/brimdata/super / newMetadataPruner

Function newMetadataPruner

compiler/optimizer/pruner.go:162–184  ·  view source on GitHub ↗
(pred dag.Expr)

Source from the content-addressed store, hash-verified

160}
161
162func newMetadataPruner(pred dag.Expr) dag.Expr {
163 switch e := pred.(type) {
164 case *dag.BinaryExpr:
165 return metaPrunerBinaryExpr(e)
166 case *dag.RegexpSearchExpr:
167 this, ok := e.Expr.(*dag.ThisExpr)
168 if !ok {
169 return nil
170 }
171 prefix := regexpPrefix(e.Pattern)
172 maxPrefix := regexpMaxPrefix(prefix)
173 if prefix == "" || maxPrefix == "" {
174 return nil
175 }
176 min := &dag.PrimitiveExpr{Kind: "PrimitiveExpr", Value: sup.QuotedString(prefix)}
177 max := &dag.PrimitiveExpr{Kind: "PrimitiveExpr", Value: sup.QuotedString(maxPrefix)}
178 return dag.NewBinaryExpr("and",
179 compare("<=", min, dag.NewThis(append(slices.Clone(this.Path), "max"))),
180 compare(">", max, dag.NewThis(append(slices.Clone(this.Path), "min"))))
181 default:
182 return nil
183 }
184}
185
186// regexpPrefix returns the prefix of the provided regular expression (if one
187// exists) only if the regular expression matches the beginning of a string.

Callers 2

newMetaFilterFunction · 0.85
metaPrunerBinaryExprFunction · 0.85

Calls 8

QuotedStringFunction · 0.92
NewBinaryExprFunction · 0.92
NewThisFunction · 0.92
metaPrunerBinaryExprFunction · 0.85
regexpPrefixFunction · 0.85
regexpMaxPrefixFunction · 0.85
compareFunction · 0.85
CloneMethod · 0.65

Tested by

no test coverage detected