MCPcopy
hub / github.com/grafana/tempo / compare

Method compare

pkg/traceql/ast.go:901–927  ·  view source on GitHub ↗
(o *Static)

Source from the content-addressed store, hash-verified

899}
900
901func (s Static) compare(o *Static) int {
902 if s.Type != o.Type {
903 if s.isNumeric() && o.isNumeric() {
904 return cmp.Compare(s.Float(), o.Float())
905 }
906 return cmp.Compare(s.Type, o.Type)
907 }
908
909 switch s.Type {
910 case TypeString, TypeBooleanArray:
911 return bytes.Compare(s.valBytes, o.valBytes)
912 case TypeIntArray:
913 sa, _ := s.IntArray()
914 oa, _ := o.IntArray()
915 return slices.Compare(sa, oa)
916 case TypeFloatArray:
917 sa, _ := s.FloatArray()
918 oa, _ := o.FloatArray()
919 return slices.Compare(sa, oa)
920 case TypeStringArray:
921 return slices.Compare(s.valStrings, o.valStrings)
922 case TypeNil:
923 return 0
924 default:
925 return cmp.Compare(int64(s.valScalar), int64(o.valScalar))
926 }
927}
928
929// Elements iterate over the elements of a Static value. If the Static is not an array,
930// it will loop over itself as the only element

Callers 3

TestStatic_compareFunction · 0.45
evaluateMethod · 0.45

Calls 5

isNumericMethod · 0.95
FloatMethod · 0.95
IntArrayMethod · 0.95
FloatArrayMethod · 0.95
CompareMethod · 0.45

Tested by 2

TestStatic_compareFunction · 0.36