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

Method Iterator

tempodb/encoding/vparquet3/wal_block.go:464–504  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

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