Close would close the iterator. It is important to call this when you're done with iteration.
()
| 534 | |
| 535 | // Close would close the iterator. It is important to call this when you're done with iteration. |
| 536 | func (it *Iterator) Close() { |
| 537 | if it.closed { |
| 538 | return |
| 539 | } |
| 540 | it.closed = true |
| 541 | |
| 542 | it.iitr.Close() |
| 543 | // It is important to wait for the fill goroutines to finish. Otherwise, we might leave zombie |
| 544 | // goroutines behind, which are waiting to acquire file read locks after DB has been closed. |
| 545 | waitFor := func(l list) { |
| 546 | item := l.pop() |
| 547 | for item != nil { |
| 548 | item.wg.Wait() |
| 549 | item = l.pop() |
| 550 | } |
| 551 | } |
| 552 | waitFor(it.waste) |
| 553 | waitFor(it.data) |
| 554 | |
| 555 | // TODO: We could handle this error. |
| 556 | _ = it.txn.db.vlog.decrIteratorCount() |
| 557 | atomic.AddInt32(&it.txn.numIterators, -1) |
| 558 | } |
| 559 | |
| 560 | // Next would advance the iterator by one. Always check it.Valid() after a Next() |
| 561 | // to ensure you have access to a valid it.Item(). |
nothing calls this directly
no test coverage detected