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

Function NewSearch

runtime/sam/expr/filter.go:87–99  ·  view source on GitHub ↗

NewSearch creates a filter that searches records for the given value, which must be of a type other than string. The filter matches a record that contains this value either as the value of any field or inside any set or array. It also matches a record if the string representaton of the search valu

(searchtext string, searchval super.Value, expr Evaluator)

Source from the content-addressed store, hash-verified

85// representaton of the search value appears inside inside any string-valued
86// field (or inside any element of a set or array of strings).
87func NewSearch(searchtext string, searchval super.Value, expr Evaluator) (Evaluator, error) {
88 if super.TypeUnder(searchval.Type()) == super.TypeNet {
89 return &searchCIDR{
90 net: super.DecodeNet(searchval.Bytes()),
91 bytes: searchval.Bytes(),
92 }, nil
93 }
94 typedCompare, err := Comparison("==", searchval)
95 if err != nil {
96 return nil, err
97 }
98 return &search{searchtext, typedCompare, expr}, nil
99}
100
101func (s *search) Eval(val super.Value) super.Value {
102 if s.expr != nil {

Callers 1

compileSearchMethod · 0.92

Calls 5

TypeUnderFunction · 0.92
DecodeNetFunction · 0.92
ComparisonFunction · 0.85
TypeMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected