Beispiel #1
0
func (p *stConstructor_MergedMemDB) newIterator() iter.Iterator {
	var its []iter.Iterator
	for _, m := range p.mem {
		its = append(its, m.NewIterator())
	}
	return iter.NewMergedIterator(its, comparer.BytesComparer{})
}
Beispiel #2
0
func (c *compaction) newIterator() iter.Iterator {
	s := c.s
	icmp := s.cmp

	level := c.level
	icap := 2
	if c.level == 0 {
		icap = len(c.tables[0]) + 1
	}
	its := make([]iter.Iterator, 0, icap)

	ro := &opt.ReadOptions{}

	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 := iter.NewIndexedIterator(tt.newIndexIterator(s.tops, icmp, ro))
			its = append(its, it)
		}
	}

	return iter.NewMergedIterator(its, icmp)
}
Beispiel #3
0
// newRawIterator return merged interators of current version, current frozen memdb
// and current memdb.
func (d *DB) newRawIterator(ro *opt.ReadOptions) iter.Iterator {
	s := d.s

	mem := d.getMem()
	v := s.version()

	ti := v.getIterators(ro)
	ii := make([]iter.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 iter.NewMergedIterator(ii, s.cmp)
}