// firstVal returns the first uint of the features entry with the given tag,
// or 0 if the tag does not exist.
557635
func (d *decoder) firstVal(tag int) uint {
	f := d.features[tag]
	if len(f) == 0 {
		return 0
	}
	return f[0]
}
554069
func (itr *tagBlockValueIterator) Next() TagValueElem {
	// Exit when there is no data left.
	if len(itr.data) == 0 {
		return nil
	}

	// Unmarshal next element & move data forward.
	itr.e.unmarshal(itr.data)
	itr.data = itr.data[itr.e.size:]

	assert(len(itr.e.Value()) > 0, "invalid zero-length tag value")
	return &itr.e
}
534179
func Convert_image_TagEvent_To_v1_TagEvent(in *image.TagEvent, out *v1.TagEvent, s conversion.Scope) error {
	return autoConvert_image_TagEvent_To_v1_TagEvent(in, out, s)
}
800548
func CountValues(b []byte) (int, error) {
	i := 0
	for ; len(b) > 0; i++ {
		_, tagsize, size, err := readKind(b)
		if err != nil {
			return 0, err
		}
		b = b[tagsize+size:]
	}
	return i, nil
}
24558
func (ts TimeSeries) GetFirstValues() (x, y float64) {
	x = util.Time.ToFloat64(ts.XValues[0])
	y = ts.YValues[0]
	return
}
511167
func (q *TagQuery) getInitialByMatch(expr kvRe, idCh chan schema.MKey, stopCh chan struct{}) {
	defer q.wg.Done()

	// shortcut if value == nil.
	// this will simply match any value, like ^.+. since we know that every value
	// in the index must not be empty, we can skip the matching.
	if expr.value == nil {
	VALUES1:
		for _, ids := range q.index[expr.key] {
			for id := range ids {
				select {
				case <-stopCh:
					break VALUES1
				case idCh <- id:
				}
			}
		}
		close(idCh)
		return
	}

VALUES2:
	for v, ids := range q.index[expr.key] {
		if !expr.value.MatchString(v) {
			continue
		}

		for id := range ids {
			select {
			case <-stopCh:
				break VALUES2
			case idCh <- id:
			}
		}
	}

	close(idCh)
}
361875
func (ls *LinearSeries) GetFirstValues() (x, y float64) {
	if ls.InnerSeries == nil || len(ls.XValues) == 0 {
		return
	}
	if ls.IsZero() {
		ls.computeCoefficients()
	}
	x, y = ls.GetValues(0)
	return
}
887608
func (t TagValue) Apply(err error) error {
	if err == nil {
		return nil
	}
	a := &Annotator{err, stackContext{frameInfo: stackFrameInfoForError(1, err)}}
	return a.Tag(t).Err()
}
322460
func (itr *tagValueSliceIterator) Next() ([]byte, error) {
	if len(itr.values) == 0 {
		return nil, nil
	}
	value := itr.values[0]
	itr.values = itr.values[1:]
	return value, nil
}
421142
func (t *Tag) CumValue() int64 {
	if t.CumDiv == 0 {
		return t.Cum
	}
	return t.Cum / t.CumDiv
}
447045
func NewFeaturesGetValuesBatchResult(Values []*FeatureValue) *FeaturesGetValuesBatchResult {
	s := new(FeaturesGetValuesBatchResult)
	s.Values = Values
	return s
}
366910
func (itr *tagValueMergeIterator) Next() (_ []byte, err error) {
	// Find next lowest value amongst the buffers.
	var value []byte
	for i, buf := range itr.buf {
		// Fill buffer.
		if buf == nil {
			if buf, err = itr.itrs[i].Next(); err != nil {
				return nil, err
			} else if buf != nil {
				itr.buf[i] = buf
			} else {
				continue
			}
		}

		// Find next lowest value.
		if value == nil || bytes.Compare(buf, value) == -1 {
			value = buf
		}
	}

	// Return nil if no elements remaining.
	if value == nil {
		return nil, nil
	}

	// Merge elements and clear buffers.
	for i, buf := range itr.buf {
		if buf == nil || !bytes.Equal(buf, value) {
			continue
		}
		itr.buf[i] = nil
	}
	return value, nil
}
628455
func (q *TagQuery) getInitialByTagPrefix(idCh chan schema.MKey, stopCh chan struct{}) {
	defer q.wg.Done()

TAGS:
	for tag, values := range q.index {
		if !strings.HasPrefix(tag, q.tagPrefix) {
			continue
		}

		for _, ids := range values {
			for id := range ids {
				select {
				case <-stopCh:
					break TAGS
				case idCh <- id:
				}
			}
		}
	}

	close(idCh)
}
1235674
func (s *state) varValue(name string) reflect.Value {
	for i := s.mark() - 1; i >= 0; i-- {
		if s.vars[i].name == name {
			return s.vars[i].value
		}
	}
	s.errorf("undefined variable: %s", name)
	return zero
}
635651
func (r *raftLog) FirstIndex() (uint64, error) {
	r.RLock()
	idx, err := r.getIndex(true)
	r.RUnlock()
	return idx, err
}
998777
func (txn *Txn) First(table, index string, args ...interface{}) (interface{}, error) {
	_, val, err := txn.FirstWatch(table, index, args...)
	return val, err
}
261325
func (f *IndexFile) TagValueIterator(name, key []byte) TagValueIterator {
	tblk := f.tblks[string(name)]
	if tblk == nil {
		return nil
	}

	// Find key element.
	ke := tblk.TagKeyElem(key)
	if ke == nil {
		return nil
	}

	// Merge all value series iterators together.
	return ke.TagValueIterator()
}