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

Method seekPages

pkg/parquetquery/iters.go:673–731  ·  view source on GitHub ↗

seekPages skips ahead in the current row group to the page that could contain the value at the desired row number. Does nothing if the current page is already the correct one.

(seekTo RowNumber, definitionLevel int)

Source from the content-addressed store, hash-verified

671// seekPages skips ahead in the current row group to the page that could contain the value at
672// the desired row number. Does nothing if the current page is already the correct one.
673func (c *SyncIterator) seekPages(seekTo RowNumber, definitionLevel int) (done bool, err error) {
674 if c.currPage != nil && CompareRowNumbers(definitionLevel, seekTo, c.currPageMax) >= 0 {
675 // Value not in this page
676 c.setPage(nil)
677 }
678
679 if c.currPage == nil {
680 // TODO (mdisibio) :((((((((
681 // pages.SeekToRow is more costly than expected. It doesn't reuse existing i/o
682 // so it can't be called naively every time we swap pages. We need to figure out
683 // a way to determine when it is worth calling here.
684 /*
685 // Seek into the pages. This is relative to the start of the row group
686 if seekTo[0] > 0 {
687 // Determine row delta. We subtract 1 because curr points at the previous row
688 skip := seekTo[0] - c.currRowGroupMin[0] - 1
689 if skip > 0 {
690 if err := c.currPages.SeekToRow(skip); err != nil {
691 return true, err
692 }
693 c.curr.Skip(skip)
694 }
695 }*/
696
697 for c.currPage == nil {
698 pg, err := c.currChunk.NextPage()
699 if pg == nil || err != nil {
700 // No more pages in this column chunk,
701 // cleanup and exit.
702 if errors.Is(err, io.EOF) {
703 err = nil
704 }
705 pq.Release(pg)
706 c.closeCurrRowGroup()
707 return true, err
708 }
709
710 // Skip based on row number?
711 newRN := c.curr
712 newRN.Skip(pg.NumRows() + 1)
713 if CompareRowNumbers(definitionLevel, seekTo, newRN) >= 0 {
714 c.curr.Skip(pg.NumRows())
715 pq.Release(pg)
716 continue
717 }
718
719 // Skip based on filter?
720 if c.filter != nil && !c.filter.KeepPage(pg) {
721 c.curr.Skip(pg.NumRows())
722 pq.Release(pg)
723 continue
724 }
725
726 c.setPage(pg)
727 }
728 }
729
730 return false, nil

Callers 2

SeekToMethod · 0.95
SeekToMethod · 0.80

Calls 7

setPageMethod · 0.95
closeCurrRowGroupMethod · 0.95
CompareRowNumbersFunction · 0.85
NextPageMethod · 0.80
SkipMethod · 0.80
ReleaseMethod · 0.65
KeepPageMethod · 0.65

Tested by

no test coverage detected