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

Method Elements

pkg/traceql/ast.go:931–966  ·  view source on GitHub ↗

Elements iterate over the elements of a Static value. If the Static is not an array, it will loop over itself as the only element

()

Source from the content-addressed store, hash-verified

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
931func (s Static) Elements() iter.Seq2[int, Static] {
932 return func(fn func(int, Static) bool) {
933 switch s.Type {
934 case TypeIntArray:
935 ints, _ := s.IntArray()
936 for i, n := range ints {
937 if !fn(i, NewStaticInt(n)) {
938 return
939 }
940 }
941 case TypeFloatArray:
942 floats, _ := s.FloatArray()
943 for i, f := range floats {
944 if !fn(i, NewStaticFloat(f)) {
945 return
946 }
947 }
948 case TypeStringArray:
949 strs, _ := s.StringArray()
950 for i, str := range strs {
951 if !fn(i, NewStaticString(str)) {
952 return
953 }
954 }
955 case TypeBooleanArray:
956 bools, _ := s.BooleanArray()
957 for i, b := range bools {
958 if !fn(i, NewStaticBool(b)) {
959 return
960 }
961 }
962 default:
963 fn(0, s)
964 }
965 }
966}
967
968func (s Static) Int() (int, bool) {
969 if s.Type != TypeInt {

Callers 1

executeMethod · 0.80

Calls 8

IntArrayMethod · 0.95
FloatArrayMethod · 0.95
StringArrayMethod · 0.95
BooleanArrayMethod · 0.95
NewStaticIntFunction · 0.85
NewStaticFloatFunction · 0.85
NewStaticStringFunction · 0.85
NewStaticBoolFunction · 0.85

Tested by

no test coverage detected