results/results.go
func (r ResultSet) Reduce(interval time.Duration) []ResultSet {
	sort.Sort(r)

	start := r[0].Timestamp
	end := r[len(r)-1].Timestamp

	// create the buckets
	bucketCount := getBucketCount(start, end, interval)
	buckets := make([]ResultSet, bucketCount)

	for _, result := range r {

		currentBucket := getBucketNumber(result.Timestamp, start, end, interval, bucketCount)
		buckets[currentBucket] = append(buckets[currentBucket], result)
	}

	return buckets
}
func (r ResultSet) Reduce(interval time.Duration) []ResultSet {
	sort.Sort(r)

	start := r[0].Timestamp
	end := r[len(r)-1].Timestamp

	// create the buckets
	bucketCount := getBucketCount(start, end, interval)
	buckets := make([]ResultSet, bucketCount)

	for _, result := range r {

		currentBucket := getBucketNumber(result.Timestamp, start, end, interval, bucketCount)
		buckets[currentBucket] = append(buckets[currentBucket], result)
	}

	return buckets
}
// Reduce reduces the ResultSet into buckets defined by the given interval