func()

in v1storage/series.go [620:651]


func (it *memorySeriesIterator) RangeValues(in metric.Interval) []model.SamplePair {
	// Find the first chunk for which the first sample is within the interval.
	i := sort.Search(len(it.chunks), func(i int) bool {
		return !it.chunks[i].FirstTime().Before(in.OldestInclusive)
	})
	// Only now check the last timestamp of the previous chunk (which is
	// fairly expensive).
	if i > 0 {
		lt, err := it.chunkIterator(i - 1).LastTimestamp()
		if err != nil {
			it.quarantine(err)
			return nil
		}
		if !lt.Before(in.OldestInclusive) {
			i--
		}
	}

	values := []model.SamplePair{}
	for j, c := range it.chunks[i:] {
		if c.FirstTime().After(in.NewestInclusive) {
			break
		}
		chValues, err := chunk.RangeValues(it.chunkIterator(i+j), in)
		if err != nil {
			it.quarantine(err)
			return nil
		}
		values = append(values, chValues...)
	}
	return values
}