func (c *compaction) newIterator() iterator.Iterator { s := c.s icmp := s.cmp level := c.level icap := 2 if c.level == 0 { icap = len(c.tables[0]) + 1 } its := make([]iterator.Iterator, 0, icap) ro := &opt.ReadOptions{ Flag: opt.RFDontFillCache, } if s.o.HasFlag(opt.OFParanoidCheck) { ro.Flag |= opt.RFVerifyChecksums } for i, tt := range c.tables { if len(tt) == 0 { continue } if level+i == 0 { for _, t := range tt { its = append(its, s.tops.newIterator(t, ro)) } } else { it := iterator.NewIndexedIterator(tt.newIndexIterator(s.tops, icmp, ro)) its = append(its, it) } } return iterator.NewMergedIterator(its, icmp) }
// Creates an iterator. func (c *compaction) newIterator() iterator.Iterator { // Creates iterator slice. icap := len(c.tables) if c.level == 0 { // Special case for level-0 icap = len(c.tables[0]) + 1 } its := make([]iterator.Iterator, 0, icap) // Options. ro := &opt.ReadOptions{ DontFillCache: true, } strict := c.s.o.GetStrict(opt.StrictIterator) for i, tables := range c.tables { if len(tables) == 0 { continue } // Level-0 is not sorted and may overlaps each other. if c.level+i == 0 { for _, t := range tables { its = append(its, c.s.tops.newIterator(t, nil, ro)) } } else { it := iterator.NewIndexedIterator(tables.newIndexIterator(c.s.tops, c.s.icmp, nil, ro), strict, true) its = append(its, it) } } return iterator.NewMergedIterator(its, c.s.icmp, true) }
func (p *stConstructor_MergedMemDB) newIterator() iterator.Iterator { var its []iterator.Iterator for _, m := range p.mem { its = append(its, m.NewIterator()) } return iterator.NewMergedIterator(its, comparer.BytesComparer{}) }
func (db *DB) newRawIterator(auxm *memDB, auxt tFiles, slice *util.Range, ro *opt.ReadOptions) iterator.Iterator { strict := opt.GetStrict(db.s.o.Options, ro, opt.StrictReader) em, fm := db.getMems() v := db.s.version() tableIts := v.getIterators(slice, ro) n := len(tableIts) + len(auxt) + 3 its := make([]iterator.Iterator, 0, n) if auxm != nil { ami := auxm.NewIterator(slice) ami.SetReleaser(&memdbReleaser{m: auxm}) its = append(its, ami) } for _, t := range auxt { its = append(its, v.s.tops.newIterator(t, slice, ro)) } emi := em.NewIterator(slice) emi.SetReleaser(&memdbReleaser{m: em}) its = append(its, emi) if fm != nil { fmi := fm.NewIterator(slice) fmi.SetReleaser(&memdbReleaser{m: fm}) its = append(its, fmi) } its = append(its, tableIts...) mi := iterator.NewMergedIterator(its, db.s.icmp, strict) mi.SetReleaser(&versionReleaser{v: v}) return mi }
func (c *compaction) newIterator() iterator.Iterator { s := c.s level := c.level icap := 2 if c.level == 0 { icap = len(c.tables[0]) + 1 } its := make([]iterator.Iterator, 0, icap) ro := &opt.ReadOptions{ DontFillCache: true, } strict := s.o.GetStrict(opt.StrictIterator) for i, tt := range c.tables { if len(tt) == 0 { continue } if level+i == 0 { for _, t := range tt { its = append(its, s.tops.newIterator(t, nil, ro)) } } else { it := iterator.NewIndexedIterator(tt.newIndexIterator(s.tops, s.icmp, nil, ro), strict, true) its = append(its, it) } } return iterator.NewMergedIterator(its, s.icmp, true) }
func (mc *stConstructor_MergedMemDB) newIterator() iterator.Iterator { var ii []iterator.Iterator for _, db := range mc.db { ii = append(ii, db.NewIterator()) } return iterator.NewMergedIterator(ii, comparer.DefaultComparer, true) }
// newRawIterator return merged interators of current version, current frozen memdb // and current memdb. func (d *DB) newRawIterator(ro *opt.ReadOptions) iterator.Iterator { s := d.s mem := d.getMem() v := s.version() ti := v.getIterators(ro) ii := make([]iterator.Iterator, 0, len(ti)+2) ii = append(ii, mem.cur.NewIterator()) if mem.froze != nil { ii = append(ii, mem.froze.NewIterator()) } ii = append(ii, ti...) return iterator.NewMergedIterator(ii, s.cmp) }
func (db *DB) newRawIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator { em, fm := db.getMems() v := db.s.version() ti := v.getIterators(slice, ro) n := len(ti) + 2 i := make([]iterator.Iterator, 0, n) i = append(i, em.NewIterator(slice)) if fm != nil { i = append(i, fm.NewIterator(slice)) } i = append(i, ti...) strict := db.s.o.GetStrict(opt.StrictIterator) || ro.GetStrict(opt.StrictIterator) mi := iterator.NewMergedIterator(i, db.s.icmp, strict) mi.SetReleaser(&versionReleaser{v: v}) return mi }
func (db *DB) newRawIterator(ro *opt.ReadOptions) iterator.Iterator { s := db.s mem, frozenMem := db.getMem() v := s.version() tableIters := v.getIterators(ro) iters := make([]iterator.Iterator, 0, len(tableIters)+2) iters = append(iters, mem.NewIterator()) if frozenMem != nil { iters = append(iters, frozenMem.NewIterator()) } iters = append(iters, tableIters...) strict := s.o.GetStrict(opt.StrictIterator) || ro.GetStrict(opt.StrictIterator) mi := iterator.NewMergedIterator(iters, s.cmp, strict) mi.SetReleaser(&versionReleaser{v: v}) return mi }
func (db *DB) newRawIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator { em, fm := db.getMems() v := db.s.version() ti := v.getIterators(slice, ro) n := len(ti) + 2 i := make([]iterator.Iterator, 0, n) emi := em.mdb.NewIterator(slice) emi.SetReleaser(&memdbReleaser{m: em}) i = append(i, emi) if fm != nil { fmi := fm.mdb.NewIterator(slice) fmi.SetReleaser(&memdbReleaser{m: fm}) i = append(i, fmi) } i = append(i, ti...) strict := opt.GetStrict(db.s.o.Options, ro, opt.StrictReader) mi := iterator.NewMergedIterator(i, db.s.icmp, strict) mi.SetReleaser(&versionReleaser{v: v}) return mi }