func NewHistogramFromFile(name string) *Histogram {
	data, err := ioutil.ReadFile(name)
	if err != nil {
		util.Fatalf("load histogram file %s failed %v", name, err)
	}
	lines := strings.Split(strings.TrimSpace(string(data)), "\n")
	line := strings.Split(strings.TrimSpace(lines[0]), "\t")
	if line[0] != "BlockSize" {
		util.Fatalf("First line of histogram is not the BlockSize but %s", line)
	}
	blockSize, err := strconv.ParseInt(line[1], 10, 64)
	if err != nil {
		util.Fatalf("parse BlockSize failed %v", err)
	}
	ay := make([]bucketInfo, 0, len(lines[1:]))
	maxLocation := int64(0)
	for _, s := range lines[1:] {
		s = strings.TrimSpace(s)
		if len(s) == 0 {
			break
		}
		line = strings.Split(s, "\t")
		location, _ := strconv.ParseInt(line[0], 10, 64)
		if maxLocation < location {
			maxLocation = location
		}
		value, _ := strconv.ParseInt(line[1], 10, 64)
		ay = append(ay, bucketInfo{location: location, value: value})
	}
	buckets := make([]int64, maxLocation+1)
	for _, b := range ay {
		buckets[b.location] = b.value
	}
	return NewHistogram(buckets, blockSize)
}
NewHistogramFromFile creates a Histogram generator from file.
package generator
import (
	"io/ioutil"
	"math/rand"
	"strconv"
	"strings"
	"github.com/pingcap/go-ycsb/pkg/util"
)
type Histogram struct {
	Number
	blockSize    int64
	buckets      []int64
	area         int64
	weightedArea int64
}
func NewHistogram(buckets []int64, blockSize int64) *Histogram {
	var (
		area         int64
		weightedArea int64
	)
	for i, b := range buckets {
		area += b
		weightedArea += int64(i) * b
	}
	return &Histogram{
		buckets:      buckets,
		blockSize:    blockSize,
		area:         area,
		weightedArea: weightedArea,
	}
}
type bucketInfo struct {
	location int64
	value    int64
}