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

Function makePipelineWithRowGroups

tempodb/encoding/vparquet4/block_search.go:118–257  ·  view source on GitHub ↗
(ctx context.Context, req *tempopb.SearchRequest, pf *parquet.File, rgs []parquet.RowGroup, dc backend.DedicatedColumns)

Source from the content-addressed store, hash-verified

116}
117
118func makePipelineWithRowGroups(ctx context.Context, req *tempopb.SearchRequest, pf *parquet.File, rgs []parquet.RowGroup, dc backend.DedicatedColumns) pq.Iterator {
119 makeIter := makeIterFunc(ctx, rgs, pf)
120
121 // Wire up iterators
122 var resourceIters []pq.Iterator
123 var traceIters []pq.Iterator
124
125 // Dedicated column mappings
126 spanAndResourceColumnMapping := dedicatedColumnsToColumnMapping(dc)
127
128 otherAttrConditions := map[string]string{}
129
130 for k, v := range req.Tags {
131 // dedicated attribute columns
132 if c, ok := spanAndResourceColumnMapping.get(k); ok {
133 resourceIters = append(resourceIters, makeIter(c.ColumnPath, pq.NewSubstringPredicate(v), ""))
134 continue
135 }
136
137 column := labelMappings[k]
138 // if we don't have a column mapping then pass it forward to otherAttribute handling
139 if column == "" {
140 otherAttrConditions[k] = v
141 continue
142 }
143
144 // most columns are just a substring predicate over the column, but we have
145 // special handling for http status code and span status
146 if k == LabelHTTPStatusCode {
147 if i, err := strconv.Atoi(v); err == nil {
148 resourceIters = append(resourceIters, makeIter(column, pq.NewIntBetweenPredicate(int64(i), int64(i)), ""))
149 continue
150 }
151 // Non-numeric string field
152 otherAttrConditions[k] = v
153 continue
154 }
155 if k == LabelStatusCode {
156 code := StatusCodeMapping[v]
157 resourceIters = append(resourceIters, makeIter(column, pq.NewIntBetweenPredicate(int64(code), int64(code)), ""))
158 continue
159 }
160
161 if k == LabelRootServiceName || k == LabelRootSpanName {
162 traceIters = append(traceIters, makeIter(column, pq.NewSubstringPredicate(v), ""))
163 } else {
164 resourceIters = append(resourceIters, makeIter(column, pq.NewSubstringPredicate(v), ""))
165 }
166 }
167
168 // Generic attribute conditions?
169 if len(otherAttrConditions) > 0 {
170 // We are looking for one or more foo=bar attributes that aren't
171 // projected to their own columns, they are in the generic Key/Value
172 // columns at the resource or span levels. We want to search
173 // both locations. But we also only want to read the columns once.
174
175 keys := make([]string, 0, len(otherAttrConditions))

Callers 1

searchRawFunction · 0.70

Calls 4

DurationMethod · 0.80
makeIterFuncFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected