diff --git a/db.go b/db.go index aee8d899a7..c2a5ed0f00 100644 --- a/db.go +++ b/db.go @@ -930,9 +930,7 @@ func (d *DB) newIterInternal(batch *Batch, s *Snapshot, o *IterOptions) *Iterato batch: batch, newIters: d.newIters, seqNum: seqNum, - newRangeKeyIter: func(it *iteratorRangeKeyState) keyspan.FragmentIterator { - return d.newRangeKeyIter(it, seqNum, batch, readState, &dbi.opts) - }, + db: d, } if o != nil { dbi.opts = *o @@ -974,7 +972,7 @@ func finishInitializingIter(buf *iterAlloc) *Iterator { if dbi.rangeKey == nil { dbi.rangeKey = iterRangeKeyStateAllocPool.Get().(*iteratorRangeKeyState) dbi.rangeKey.keys.cmp = dbi.cmp - dbi.rangeKey.rangeKeyIter = dbi.newRangeKeyIter(dbi.rangeKey) + dbi.rangeKey.rangeKeyIter = dbi.db.newRangeKeyIter(dbi.rangeKey, dbi.seqNum, dbi.batch, dbi.readState, &dbi.opts) } // Wrap the point iterator (currently dbi.iter) with an interleaving diff --git a/iterator.go b/iterator.go index 50bbc075df..fdecb2b6e3 100644 --- a/iterator.go +++ b/iterator.go @@ -184,8 +184,9 @@ type Iterator struct { batch *Batch newIters tableNewIters seqNum uint64 - // TODO(jackson): Remove when we no longer require the global arena. - newRangeKeyIter func(*iteratorRangeKeyState) keyspan.FragmentIterator + // TODO(jackson): Remove db when we no longer require the global arena for + // range keys. This reference is only temporary. + db *DB // Keeping the bools here after all the 8 byte aligned fields shrinks the // sizeof this struct by 24 bytes. @@ -1941,7 +1942,7 @@ func (i *Iterator) Clone() (*Iterator, error) { batch: i.batch, newIters: i.newIters, seqNum: i.seqNum, - newRangeKeyIter: i.newRangeKeyIter, + db: i.db, } return finishInitializingIter(buf), nil }