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

Function CompareString

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

Source from the content-addressed store, hash-verified

177}
178
179func CompareString(op string, pattern []byte) (Boolean, error) {
180 compare, ok := compareString[op]
181 if !ok {
182 return nil, fmt.Errorf("unknown string comparator: %s", op)
183 }
184 s := string(pattern)
185 return func(val super.Value) super.Value {
186 val = val.Under()
187 if val.IsNull() {
188 return super.Null
189 }
190 if val.IsError() {
191 return val
192 }
193 if val.Type().ID() == super.IDString {
194 return super.NewBool(compare(byteconv.UnsafeString(val.Bytes()), s))
195 }
196 return super.False
197 }, nil
198}
199
200var compareBytes = map[string]func([]byte, []byte) bool{
201 "==": func(a, b []byte) bool { return bytes.Equal(a, b) },

Callers 1

ComparisonFunction · 0.85

Calls 9

NewBoolFunction · 0.92
UnsafeStringFunction · 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