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

Function createIntPredicate

tempodb/encoding/vparquet5/block_traceql.go:2932–2986  ·  view source on GitHub ↗
(op traceql.Operator, operands traceql.Operands)

Source from the content-addressed store, hash-verified

2930}
2931
2932func createIntPredicate(op traceql.Operator, operands traceql.Operands) (parquetquery.Predicate, error) {
2933 if pred, handled := createExistencePredicate(op); handled {
2934 return pred, nil
2935 }
2936
2937 if len(operands) == 0 {
2938 return nil, fmt.Errorf("operands cannot be empty")
2939 }
2940
2941 var i int64
2942 switch operands[0].Type {
2943 case traceql.TypeInt:
2944 n, _ := operands[0].Int()
2945 i = int64(n)
2946 case traceql.TypeDuration:
2947 d, _ := operands[0].Duration()
2948 i = d.Nanoseconds()
2949 case traceql.TypeStatus:
2950 st, _ := operands[0].Status()
2951 i = int64(StatusCodeMapping[st.String()])
2952 case traceql.TypeKind:
2953 k, _ := operands[0].Kind()
2954 i = int64(KindMapping[k.String()])
2955 case traceql.TypeIntArray:
2956 ints, _ := operands[0].Int64Array()
2957
2958 switch op {
2959 case traceql.OpEqual, traceql.OpIn:
2960 return parquetquery.NewIntInPredicate(ints), nil
2961 case traceql.OpNotEqual, traceql.OpNotIn:
2962 return parquetquery.NewIntNotInPredicate(ints), nil
2963 default:
2964 return nil, fmt.Errorf("operator not supported for int arrays: %+v", op)
2965 }
2966 default:
2967 return nil, fmt.Errorf("operand is not int, int array, duration, status or kind: %s", operands[0].EncodeToString(false))
2968 }
2969
2970 switch op {
2971 case traceql.OpEqual:
2972 return parquetquery.NewIntEqualPredicate(i), nil
2973 case traceql.OpNotEqual:
2974 return parquetquery.NewIntNotEqualPredicate(i), nil
2975 case traceql.OpGreater:
2976 return parquetquery.NewIntGreaterPredicate(i), nil
2977 case traceql.OpGreaterEqual:
2978 return parquetquery.NewIntGreaterEqualPredicate(i), nil
2979 case traceql.OpLess:
2980 return parquetquery.NewIntLessPredicate(i), nil
2981 case traceql.OpLessEqual:
2982 return parquetquery.NewIntLessEqualPredicate(i), nil
2983 default:
2984 return nil, fmt.Errorf("operator not supported for integers: %+v", op)
2985 }
2986}
2987
2988func createFloatPredicate(op traceql.Operator, operands traceql.Operands) (parquetquery.Predicate, error) {
2989 if pred, handled := createExistencePredicate(op); handled {

Callers 12

createEventIteratorFunction · 0.70
createSpanIteratorFunction · 0.70
createPredicateFunction · 0.70
createDurationPredicateFunction · 0.70
createAttributeIteratorFunction · 0.70
createSpanIteratorsFunction · 0.70
createEventIteratorsFunction · 0.70

Calls 15

NewIntInPredicateFunction · 0.92
NewIntNotInPredicateFunction · 0.92
NewIntEqualPredicateFunction · 0.92
NewIntNotEqualPredicateFunction · 0.92
NewIntGreaterPredicateFunction · 0.92
NewIntLessPredicateFunction · 0.92
NewIntLessEqualPredicateFunction · 0.92
IntMethod · 0.80
DurationMethod · 0.80
StatusMethod · 0.80
KindMethod · 0.80

Tested by

no test coverage detected