func (si *SeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePair {
	<-si.ready
	if si.curr == nil {
		return *si.last
	}
	for {
		if si.curr.Timestamp > t {
			return *si.last
		}
		si.last.Timestamp = si.curr.Timestamp
		si.last.Value = si.curr.Value
		ok := si.iter.Scan(&si.curr.Timestamp, &si.curr.Value)
		if !ok {
			si.curr = nil
			return *si.last
		}
	}
}
ValueAtOrBeforeTime gets the value that is closest before the given time. In case a value
exists at precisely the given time, that value is returned. If no
applicable value exists, ZeroSamplePair is returned. This function assumes that
ValueAtOrBeforeTime will be called only with incrementing values of t and that
this SeriesIterator will only call either ValueAtOrBeforeTime or RangeValues, but
not both functions.
package cassandra
import (
	"github.com/digitalocean/vulcan/convert"
	"github.com/gocql/gocql"
	"github.com/prometheus/common/model"
	"github.com/prometheus/prometheus/storage/local"
	"github.com/prometheus/prometheus/storage/metric"
	log "github.com/Sirupsen/logrus"
)
const fetchUncompressedSQLIter = `SELECT at, value FROM uncompressed WHERE fqmn = ? AND at >= ? AND at <= ? ORDER BY at ASC`
var _ local.SeriesIterator = &SeriesIterator{}  
type SeriesIterator struct {
	iter       *gocql.Iter
	fqmn       string
	m          metric.Metric
	curr, last *model.SamplePair
	list       []model.SamplePair
	ready      chan struct{}
}
type SeriesIteratorConfig struct {
	Session       *gocql.Session
	Metric        metric.Metric
	After, Before model.Time
	PageSize      int
	Prefetch      float64
}
func NewSeriesIterator(config *SeriesIteratorConfig) *SeriesIterator {
	ts := convert.MetricToTimeSeries(config.Metric)
	si := &SeriesIterator{
		m:    config.Metric,
		fqmn: ts.ID(),
		curr: &model.SamplePair{
			Timestamp: model.ZeroSamplePair.Timestamp,
			Value:     model.ZeroSamplePair.Value,
		},
		last: &model.SamplePair{
			Timestamp: model.ZeroSamplePair.Timestamp,
			Value:     model.ZeroSamplePair.Value,
		},
		list:  []model.SamplePair{},
		ready: make(chan struct{}),
	}
	go func() {
		si.iter = config.Session.Query(fetchUncompressedSQLIter, si.fqmn, config.After, config.Before).
			PageSize(config.PageSize).
			Prefetch(config.Prefetch).
			Iter()
		close(si.ready)
	}()
	return si
}