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

Method Next

tempodb/encoding/vparquet5/block_traceql.go:1251–1316  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1249}
1250
1251func (i *bridgeIterator) Next() (*parquetquery.IteratorResult, error) {
1252 // drain current buffer
1253 if ret, ok := i.pop(); ok {
1254 return ret, nil
1255 }
1256
1257 // get next spanset
1258 i.reset()
1259
1260 for {
1261 res, err := i.iter.Next()
1262 if err != nil {
1263 return nil, err
1264 }
1265 if res == nil {
1266 return nil, nil
1267 }
1268
1269 // The spanset is in the OtherEntries
1270 iface := res.OtherValueFromKey(otherEntrySpansetKey)
1271 if iface == nil {
1272 return nil, fmt.Errorf("engine assumption broken: spanset not found in other entries in bridge")
1273 }
1274 spanset, ok := iface.(*traceql.Spanset)
1275 if !ok {
1276 return nil, fmt.Errorf("engine assumption broken: spanset is not of type *traceql.Spanset in bridge")
1277 }
1278
1279 filteredSpansets, err := i.cb(spanset)
1280 if errors.Is(err, io.EOF) {
1281 return nil, nil
1282 }
1283 if err != nil {
1284 return nil, err
1285 }
1286 // if the filter removed all spansets then let's release all back to the pool
1287 // no reason to try anything more nuanced than this. it will handle nearly all cases
1288 if len(filteredSpansets) == 0 {
1289 for _, s := range spanset.Spans {
1290 putSpan(s.(*span))
1291 }
1292 putSpanset(spanset)
1293 }
1294
1295 // flatten spans into i.currentSpans
1296 for _, ss := range filteredSpansets {
1297 for idx, s := range ss.Spans {
1298 span := s.(*span)
1299
1300 // mark whether this is the last span in the spanset
1301 span.cbSpansetFinal = idx == len(ss.Spans)-1
1302 span.cbSpanset = ss
1303 i.nextSpans = append(i.nextSpans, span)
1304 }
1305 }
1306
1307 sort.Slice(i.nextSpans, func(j, k int) bool {
1308 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