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

Function createBytesPredicate

tempodb/encoding/vparquet3/block_traceql.go:2111–2170  ·  view source on GitHub ↗
(op traceql.Operator, operands traceql.Operands, isSpan bool)

Source from the content-addressed store, hash-verified

2109}
2110
2111func createBytesPredicate(op traceql.Operator, operands traceql.Operands, isSpan bool) (parquetquery.Predicate, error) {
2112 if pred, handled := createExistencePredicate(op); handled {
2113 return pred, nil
2114 }
2115
2116 switch operands[0].Type {
2117 case traceql.TypeString:
2118 s := operands[0].EncodeToString(false)
2119
2120 var id []byte
2121 var err error
2122 if isSpan {
2123 id, err = util.HexStringToSpanID(s)
2124 } else {
2125 id, err = util.HexStringToTraceID(s)
2126 }
2127
2128 if err != nil {
2129 return nil, nil
2130 }
2131
2132 switch op {
2133 case traceql.OpEqual:
2134 return parquetquery.NewByteEqualPredicate(id), nil
2135 case traceql.OpNotEqual:
2136 return parquetquery.NewByteNotEqualPredicate(id), nil
2137 default:
2138 return nil, fmt.Errorf("operator not supported for IDs: %+v", op)
2139 }
2140 case traceql.TypeStringArray:
2141 strs, _ := operands[0].StringArray()
2142 ids := make([][]byte, 0, len(strs))
2143
2144 for _, s := range strs {
2145 var id []byte
2146 var err error
2147 if isSpan {
2148 id, err = util.HexStringToSpanID(s)
2149 } else {
2150 id, err = util.HexStringToTraceID(s)
2151 }
2152
2153 if err != nil {
2154 return nil, nil
2155 }
2156 ids = append(ids, id)
2157 }
2158
2159 switch op {
2160 case traceql.OpEqual, traceql.OpIn:
2161 return parquetquery.NewByteInPredicate(ids), nil
2162 case traceql.OpNotEqual, traceql.OpNotIn:
2163 return parquetquery.NewByteNotInPredicate(ids), nil
2164 default:
2165 return nil, fmt.Errorf("operator not supported for IDs: %+v", op)
2166 }
2167 default:
2168 return nil, fmt.Errorf("operand is not string or string array: %s", operands[0])

Callers 2

createSpanIteratorFunction · 0.70
createTraceIteratorFunction · 0.70

Calls 9

HexStringToSpanIDFunction · 0.92
HexStringToTraceIDFunction · 0.92
NewByteEqualPredicateFunction · 0.92
NewByteNotEqualPredicateFunction · 0.92
NewByteInPredicateFunction · 0.92
NewByteNotInPredicateFunction · 0.92
EncodeToStringMethod · 0.80
StringArrayMethod · 0.80
createExistencePredicateFunction · 0.70

Tested by

no test coverage detected