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

Method Iterator

tempodb/encoding/vparquet4/wal_block.go:475–515  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

473}
474
475func (b *walBlock) Iterator(ctx context.Context) (common.Iterator, error) {
476 flushed := b.readFlushes()
477 bookmarks := make([]*bookmark[parquet.Row], 0, len(flushed))
478
479 for _, page := range flushed {
480 iter, err := page.rowIterator(ctx)
481 if err != nil {
482 return nil, fmt.Errorf("error creating iterator for %s: %w", page.path, err)
483 }
484 bookmarks = append(bookmarks, newBookmark[parquet.Row](iter))
485 }
486
487 sch := parquet.SchemaOf(new(Trace))
488 iter := newMultiblockIterator(bookmarks, func(rows []parquet.Row) (parquet.Row, error) {
489 if len(rows) == 1 {
490 return rows[0], nil
491 }
492
493 ts := make([]*Trace, 0, len(rows))
494 for _, row := range rows {
495 tr := &Trace{}
496 err := sch.Reconstruct(tr, row)
497 if err != nil {
498 return nil, err
499 }
500 ts = append(ts, tr)
501 completeBlockRowPool.Put(row)
502 }
503
504 // TODO: walBlock.Iterator is called when creating a complete block from a wal block. it would be
505 // nice to track trace disconnectd metrics while doing this. unfortunately there is no clean way for this
506 // code to know that it's being called in that context. perhaps find a way to do this in the future
507 t := combineTraces(ts...)
508 row := completeBlockRowPool.Get()
509 row = sch.Deconstruct(row, t)
510
511 return row, nil
512 })
513
514 return newCommonIterator(b.meta, iter, sch), nil
515}
516
517func (b *walBlock) Clear() error {
518 var errs multierror.MultiError

Callers

nothing calls this directly

Calls 7

readFlushesMethod · 0.95
newMultiblockIteratorFunction · 0.70
combineTracesFunction · 0.70
newCommonIteratorFunction · 0.70
GetMethod · 0.65
rowIteratorMethod · 0.45
PutMethod · 0.45

Tested by

no test coverage detected