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

Method next

pkg/parquetquery/nil_iter.go:93–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91}
92
93func (c *NilSyncIterator) next() (RowNumber, *pq.Value, error) {
94 var lastValue *pq.Value
95 lastRowNumber := EmptyRowNumber()
96 for {
97 if c.currRowGroup == nil {
98 rg, minRN, maxRN := c.popRowGroup()
99 if rg == nil {
100 // no more rows, return last row if we still haven't found the value
101 if lastValue != nil && !c.valueFound && lastRowNumber.Valid() && !EqualRowNumber(lastValue.DefinitionLevel(), c.lastRowNumberReturned, lastRowNumber) {
102 c.lastRowNumberReturned = lastRowNumber
103 return lastRowNumber, lastValue, nil
104 }
105 return EmptyRowNumber(), nil, nil
106 }
107
108 cc := &ColumnChunkHelper{ColumnChunk: rg.ColumnChunks()[c.column]}
109 if c.filter != nil && !c.filter.KeepColumnChunk(cc) {
110 cc.Close()
111 continue
112 }
113
114 c.setRowGroup(rg, minRN, maxRN, cc)
115 }
116
117 if c.currPage == nil {
118 pg, err := c.currChunk.NextPage()
119 if pg == nil || errors.Is(err, io.EOF) {
120 // This row group is exhausted
121 c.closeCurrRowGroup()
122 continue
123 }
124 if err != nil {
125 return EmptyRowNumber(), nil, err
126 }
127 if c.filter != nil && !c.filter.KeepPage(pg) {
128 // This page filtered out
129 c.curr.Skip(pg.NumRows())
130 pq.Release(pg)
131 continue
132 }
133 c.setPage(pg)
134 }
135
136 // Read next batch of values if needed
137 if c.currBuf == nil {
138 c.currBuf = syncIteratorPoolGet(c.readSize, 0)
139 }
140
141 if c.currBufN >= len(c.currBuf) || len(c.currBuf) == 0 {
142 c.currBuf = c.currBuf[:cap(c.currBuf)]
143 n, err := c.currValues.ReadValues(c.currBuf)
144 if err != nil && !errors.Is(err, io.EOF) {
145 return EmptyRowNumber(), nil, err
146 }
147 c.currBuf = c.currBuf[:n]
148 c.currBufN = 0
149 if n == 0 {
150 // This value reader and page are exhausted.

Callers 2

NextMethod · 0.95
SeekToMethod · 0.95

Calls 15

CloseMethod · 0.95
EmptyRowNumberFunction · 0.85
EqualRowNumberFunction · 0.85
syncIteratorPoolGetFunction · 0.85
popRowGroupMethod · 0.80
ValidMethod · 0.80
setRowGroupMethod · 0.80
NextPageMethod · 0.80
closeCurrRowGroupMethod · 0.80
SkipMethod · 0.80
setPageMethod · 0.80
KeepColumnChunkMethod · 0.65

Tested by

no test coverage detected