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

Function CompareBytes

runtime/sam/expr/boolean.go:209–229  ·  view source on GitHub ↗
(op string, pattern []byte)

Source from the content-addressed store, hash-verified

207}
208
209func CompareBytes(op string, pattern []byte) (Boolean, error) {
210 compare, ok := compareBytes[op]
211 if !ok {
212 return nil, fmt.Errorf("unknown bytes comparator: %s", op)
213 }
214 return func(val super.Value) super.Value {
215 val = val.Under()
216 if val.IsNull() {
217 return super.Null
218 }
219 if val.IsError() {
220 return val
221 }
222 v := false
223 switch val.Type().ID() {
224 case super.IDBytes, super.IDType:
225 v = compare(val.Bytes(), pattern)
226 }
227 return super.NewBool(v)
228 }, nil
229}
230
231func CompileRegexp(pattern string) (*regexp.Regexp, error) {
232 re, err := regexp.Compile(pattern)

Callers 1

ComparisonFunction · 0.85

Calls 8

NewBoolFunction · 0.92
compareFunction · 0.85
UnderMethod · 0.80
IsNullMethod · 0.80
IsErrorMethod · 0.80
IDMethod · 0.65
TypeMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected