func (itr *tagKeyMergeIterator) Next() TagKeyElem {
	var key []byte
	for i, buf := range itr.buf {
		if buf == nil {
			if buf = itr.itrs[i].Next(); buf != nil {
				itr.buf[i] = buf
			} else {
				continue
			}
		}
		if key == nil || bytes.Compare(buf.Key(), key) == -1 {
			key = buf.Key()
		}
	}
	if key == nil {
		return nil
	}
	itr.e = itr.e[:0]
	for i, buf := range itr.buf {
		if buf == nil || !bytes.Equal(buf.Key(), key) {
			continue
		}
		itr.e = append(itr.e, buf)
		itr.buf[i] = nil
	}
	return itr.e
}
Next returns the element with the next lowest key across the iterators.

If multiple iterators contain the same key then the first is returned
and the remaining ones are skipped.
package tsi1
import (
	"bytes"
	"encoding/binary"
	"fmt"
	"io"
	"github.com/influxdata/influxdb/tsdb"
)
const LoadFactor = 80
type MeasurementElem interface {
	Name() []byte
	Deleted() bool
}
type MeasurementElems []MeasurementElem
func (a MeasurementElems) Len() int           { return len(a) }
func (a MeasurementElems) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a MeasurementElems) Less(i, j int) bool { return bytes.Compare(a[i].Name(), a[j].Name()) == -1 }
type MeasurementIterator interface {
	Next() MeasurementElem
}
func MergeMeasurementIterators(itrs ...MeasurementIterator) MeasurementIterator {
	if len(itrs) == 0 {
		return nil
	}
	return &measurementMergeIterator{
		e:    make(measurementMergeElem, 0, len(itrs)),
		buf:  make([]MeasurementElem, len(itrs)),
		itrs: itrs,
	}
}
type measurementMergeIterator struct {
	e    measurementMergeElem
	buf  []MeasurementElem
	itrs []MeasurementIterator
}
func (itr *measurementMergeIterator) Next() MeasurementElem {
	var name []byte
	for i, buf := range itr.buf {
		if buf == nil {
			if buf = itr.itrs[i].Next(); buf != nil {
				itr.buf[i] = buf
			} else {
				continue
			}
		}
		if name == nil || bytes.Compare(itr.buf[i].Name(), name) == -1 {
			name = itr.buf[i].Name()
		}
	}
	if name == nil {
		return nil
	}
	itr.e = itr.e[:0]
	for i, buf := range itr.buf {
		if buf == nil || !bytes.Equal(buf.Name(), name) {
			continue
		}
		itr.e = append(itr.e, buf)
		itr.buf[i] = nil
	}
	return itr.e
}
type measurementMergeElem []MeasurementElem
func (p measurementMergeElem) Name() []byte {
	if len(p) == 0 {
		return nil
	}
	return p[0].Name()
}
func (p measurementMergeElem) Deleted() bool {
	if len(p) == 0 {
		return false
	}
	return p[0].Deleted()
}
type tsdbMeasurementIteratorAdapter struct {
	itr MeasurementIterator
}
func NewTSDBMeasurementIteratorAdapter(itr MeasurementIterator) tsdb.MeasurementIterator {
	if itr == nil {
		return nil
	}
	return &tsdbMeasurementIteratorAdapter{itr: itr}
}
func (itr *tsdbMeasurementIteratorAdapter) Close() error { return nil }
func (itr *tsdbMeasurementIteratorAdapter) Next() ([]byte, error) {
	for {
		e := itr.itr.Next()
		if e == nil {
			return nil, nil
		} else if e.Deleted() {
			continue
		}
		return e.Name(), nil
	}
}
type TagKeyElem interface {
	Key() []byte
	Deleted() bool
	TagValueIterator() TagValueIterator
}
type TagKeyIterator interface {
	Next() TagKeyElem
}
type tsdbTagKeyIteratorAdapter struct {
	itr TagKeyIterator
}
func NewTSDBTagKeyIteratorAdapter(itr TagKeyIterator) tsdb.TagKeyIterator {
	if itr == nil {
		return nil
	}
	return &tsdbTagKeyIteratorAdapter{itr: itr}
}
func (itr *tsdbTagKeyIteratorAdapter) Close() error { return nil }
func (itr *tsdbTagKeyIteratorAdapter) Next() ([]byte, error) {
	for {
		e := itr.itr.Next()
		if e == nil {
			return nil, nil
		} else if e.Deleted() {
			continue
		}
		return e.Key(), nil
	}
}
func MergeTagKeyIterators(itrs ...TagKeyIterator) TagKeyIterator {
	if len(itrs) == 0 {
		return nil
	}
	return &tagKeyMergeIterator{
		e:    make(tagKeyMergeElem, 0, len(itrs)),
		buf:  make([]TagKeyElem, len(itrs)),
		itrs: itrs,
	}
}
type tagKeyMergeIterator struct {
	e    tagKeyMergeElem
	buf  []TagKeyElem
	itrs []TagKeyIterator
}