func Fetch(
	p basicPageType,
	start, end float64,
	record *Record,
	result Appender) (keepGoing bool) {
	lastIdx := p.FindGreaterOrEqual(end)
	if lastIdx == 0 {
		return true
	}
	firstIdx := p.FindGreater(start) - 1
	if firstIdx < 0 {
		keepGoing = true
		firstIdx = 0
	}
	for i := lastIdx - 1; i >= firstIdx; i-- {
		p.StoreIndexToRecord(i, record)
		if !result.Append(record) {
			return false
		}
	}
	return
}
Fetch iterates over page data p from time start to time end.
Fetch adds the data to result in descending order by time starting
just before end and ending on or before start.
start and end are seconds after Jan 1 1970.
If caller should add more data from previous pages because caller is not
back far enough in time, Fetch returns true. Otherwise Fetch returns false.
package store
import (
	"github.com/Symantec/scotty/store/btreepq"
	"github.com/google/btree"
	"reflect"
	"sort"
)
var (
	kTsAndValueSize = tsAndValueSize()
)
func tsAndValueSize() uint {
	var p pageType
	return uint(reflect.TypeOf(p).Elem().Size())
}
type basicPageType interface {
	Clear()
	IsFull() bool
	FindGreaterOrEqual(ts float64) int
	FindGreater(ts float64) int
	Len() int
	StoreIndexToRecord(idx int, record *Record)
}
type tsValueType struct {
	TimeStamp float64
	Value     interface{}  
}
type tsPageType []tsValueType
func (p tsPageType) IsFull() bool {
	return len(p) == cap(p)
}
func (p *tsPageType) Clear() {
	*p = (*p)[:0]
}
func (p tsPageType) Latest() (latest float64, ok bool) {
	length := len(p)
	if length == 0 {
		return
	}
	latest = p[length-1].TimeStamp
	ok = true
	return
}
func (p tsPageType) Len() int {
	return len(p)
}
func (p *tsPageType) Add(ts float64) {
	length := len(*p)
	*p = (*p)[0 : length+1]
	(*p)[length].TimeStamp = ts
}
func (p tsPageType) StoreIndexToRecord(idx int, record *Record) {
	record.TimeStamp = p[idx].TimeStamp
}
func (p tsPageType) FindGreaterOrEqual(ts float64) int {
	return sort.Search(
		len(p),
		func(idx int) bool { return p[idx].TimeStamp >= ts })
}
func (p tsPageType) FindGreater(ts float64) int {
	return sort.Search(
		len(p),
		func(idx int) bool { return p[idx].TimeStamp > ts })
}
type pageType []tsValueType
func (p pageType) Len() int {
	return len(p)
}
func (p *pageType) Add(val tsValueType) {
	length := len(*p)
	*p = (*p)[0 : length+1]
	(*p)[length] = val
}
func (p *pageType) Clear() {
	*p = (*p)[:0]
}
func (p pageType) Latest() (latest float64, ok bool) {
	length := len(p)
	if length == 0 {
		return
	}
	latest = p[length-1].TimeStamp
	ok = true
	return
}
func (p pageType) IsFull() bool {
	return len(p) == cap(p)
}
func (p pageType) StoreIndexToRecord(idx int, record *Record) {
	record.TimeStamp = p[idx].TimeStamp
	record.setValue(p[idx].Value)
}
func (p pageType) FindGreaterOrEqual(ts float64) int {
	return sort.Search(
		len(p),
		func(idx int) bool { return p[idx].TimeStamp >= ts })
}
func (p pageType) FindGreater(ts float64) int {
	return sort.Search(
		len(p),
		func(idx int) bool { return p[idx].TimeStamp > ts })
}
type pageMetaDataType struct {
	seqNo uint64
	ts    float64
	owner pageOwnerType
}
func (m *pageMetaDataType) SetSeqNo(i uint64) {
	m.seqNo = i
}
func (m *pageMetaDataType) SeqNo() uint64 {
	return m.seqNo
}
func (m *pageMetaDataType) SetTS(ts float64) {
	m.ts = ts
}
func (m *pageMetaDataType) TS() float64 {
	return m.ts
}
type pageWithMetaDataType struct {
	pageMetaDataType
	values []tsValueType
}
func newPageWithMetaDataType(bytesPerPage uint) *pageWithMetaDataType {
	return &pageWithMetaDataType{
		values: make(pageType, 0, bytesPerPage/kTsAndValueSize)}
}
func (p *pageWithMetaDataType) Values() *pageType {
	return (*pageType)(&p.values)
}
func (p *pageWithMetaDataType) Times() *tsPageType {
	return (*tsPageType)(&p.values)
}
func (p *pageWithMetaDataType) ValuePage() basicPageType {
	return p.Values()
}
func (p *pageWithMetaDataType) TimePage() basicPageType {
	return p.Times()
}
func (p *pageWithMetaDataType) Less(than btree.Item) bool {
	pthan := than.(btreepq.Page)
	return btreepq.IsPageLessThanThat(p, pthan)
}