()
| 91 | } |
| 92 | |
| 93 | func (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. |
no test coverage detected