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

Method Next

tempodb/encoding/vparquet4/block_traceql.go:1190–1255  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1188}
1189
1190func (i *bridgeIterator) Next() (*parquetquery.IteratorResult, error) {
1191 // drain current buffer
1192 if ret, ok := i.pop(); ok {
1193 return ret, nil
1194 }
1195
1196 // get next spanset
1197 i.reset()
1198
1199 for {
1200 res, err := i.iter.Next()
1201 if err != nil {
1202 return nil, err
1203 }
1204 if res == nil {
1205 return nil, nil
1206 }
1207
1208 // The spanset is in the OtherEntries
1209 iface := res.OtherValueFromKey(otherEntrySpansetKey)
1210 if iface == nil {
1211 return nil, fmt.Errorf("engine assumption broken: spanset not found in other entries in bridge")
1212 }
1213 spanset, ok := iface.(*traceql.Spanset)
1214 if !ok {
1215 return nil, fmt.Errorf("engine assumption broken: spanset is not of type *traceql.Spanset in bridge")
1216 }
1217
1218 filteredSpansets, err := i.cb(spanset)
1219 if errors.Is(err, io.EOF) {
1220 return nil, nil
1221 }
1222 if err != nil {
1223 return nil, err
1224 }
1225 // if the filter removed all spansets then let's release all back to the pool
1226 // no reason to try anything more nuanced than this. it will handle nearly all cases
1227 if len(filteredSpansets) == 0 {
1228 for _, s := range spanset.Spans {
1229 putSpan(s.(*span))
1230 }
1231 putSpanset(spanset)
1232 }
1233
1234 // flatten spans into i.currentSpans
1235 for _, ss := range filteredSpansets {
1236 for idx, s := range ss.Spans {
1237 span := s.(*span)
1238
1239 // mark whether this is the last span in the spanset
1240 span.cbSpansetFinal = idx == len(ss.Spans)-1
1241 span.cbSpanset = ss
1242 i.nextSpans = append(i.nextSpans, span)
1243 }
1244 }
1245
1246 sort.Slice(i.nextSpans, func(j, k int) bool {
1247 return parquetquery.CompareRowNumbers(DefinitionLevelResourceSpansILSSpan, i.nextSpans[j].rowNum, i.nextSpans[k].rowNum) == -1

Callers 1

SeekToMethod · 0.95

Calls 7

popMethod · 0.95
resetMethod · 0.95
CompareRowNumbersFunction · 0.92
OtherValueFromKeyMethod · 0.80
putSpanFunction · 0.70
putSpansetFunction · 0.70
NextMethod · 0.65

Tested by

no test coverage detected