Ejemplo n.º 1
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)
}
Ejemplo n.º 2
0
func (v *version) getIterators(ro *opt.ReadOptions) (its []iter.Iterator) {
	s := v.s
	icmp := s.cmp

	// Merge all level zero files together since they may overlap
	for _, t := range v.tables[0] {
		it := s.tops.newIterator(t, ro)
		its = append(its, it)
	}

	for _, tt := range v.tables[1:] {
		if len(tt) == 0 {
			continue
		}

		it := iter.NewIndexedIterator(tt.newIndexIterator(s.tops, icmp, ro))
		its = append(its, it)
	}

	return
}
Ejemplo n.º 3
0
// NewIterator create new iterator over the table.
func (t *Reader) NewIterator(ro opt.ReadOptionsGetter) iter.Iterator {
	index_iter := &indexIter{t: t, ro: ro}
	t.index.InitIterator(&index_iter.Iterator)
	return iter.NewIndexedIterator(index_iter)
}