Next implements the Executor interface.
(ctx context.Context, req *chunk.Chunk)
| 135 | |
| 136 | // Next implements the Executor interface. |
| 137 | func (e *ParallelNestedLoopApplyExec) Next(ctx context.Context, req *chunk.Chunk) (err error) { |
| 138 | if atomic.LoadUint32(&e.drained) == 1 { |
| 139 | req.Reset() |
| 140 | return nil |
| 141 | } |
| 142 | |
| 143 | if atomic.CompareAndSwapUint32(&e.started, 0, 1) { |
| 144 | e.workerWg.Add(1) |
| 145 | go e.outerWorker(ctx) |
| 146 | for i := 0; i < e.concurrency; i++ { |
| 147 | e.workerWg.Add(1) |
| 148 | workID := i |
| 149 | go e.innerWorker(ctx, workID) |
| 150 | } |
| 151 | e.notifyWg.Add(1) |
| 152 | go e.notifyWorker(ctx) |
| 153 | } |
| 154 | result := <-e.resultChkCh |
| 155 | if result.err != nil { |
| 156 | return result.err |
| 157 | } |
| 158 | if result.chk == nil { // no more data |
| 159 | req.Reset() |
| 160 | atomic.StoreUint32(&e.drained, 1) |
| 161 | return nil |
| 162 | } |
| 163 | req.SwapColumns(result.chk) |
| 164 | e.freeChkCh <- result.chk |
| 165 | return nil |
| 166 | } |
| 167 | |
| 168 | // Close implements the Executor interface. |
| 169 | func (e *ParallelNestedLoopApplyExec) Close() error { |
nothing calls this directly
no test coverage detected