Unexport zipf implementation details

This commit is contained in:
Alan Bernstein 2016-12-19 18:10:08 -06:00
parent eb7dfb1b99
commit 0443fa9529

View file

@ -24,11 +24,11 @@ type ZipfSetBits struct {
ProfileIDRange int64 `json:"profile-id-range"`
Iterations int `json:"iterations"`
Seed int64 `json:"seed"`
BitmapRng *rand.Zipf `json:"-"`
DB string `json:"db"`
bitmapRng *rand.Zipf `json:"-"`
ProfileRng *rand.Zipf `json:"-"`
BitmapPerm *PermutationGenerator `json:"-"`
ProfilePerm *PermutationGenerator `json:"-"`
DB string `json:"db"`
BitmapExponent float64 `json:"bitmap-exponent"`
BitmapRatio float64 `json:"bitmap-ratio"`
@ -125,12 +125,12 @@ func (b *ZipfSetBits) Init(hosts []string, agentNum int) error {
b.Name = "ZipfSetBits"
rnd := rand.New(rand.NewSource(b.Seed + int64(agentNum)))
bitmapOffset := getZipfOffset(b.BitmapIDRange, b.BitmapExponent, b.BitmapRatio)
b.BitmapRng = rand.NewZipf(rnd, b.BitmapExponent, bitmapOffset, uint64(b.BitmapIDRange-1))
b.bitmapRng = rand.NewZipf(rnd, b.BitmapExponent, bitmapOffset, uint64(b.BitmapIDRange-1))
profileOffset := getZipfOffset(b.ProfileIDRange, b.ProfileExponent, b.ProfileRatio)
b.ProfileRng = rand.NewZipf(rnd, b.ProfileExponent, profileOffset, uint64(b.ProfileIDRange-1))
b.profileRng = rand.NewZipf(rnd, b.ProfileExponent, profileOffset, uint64(b.ProfileIDRange-1))
b.BitmapPerm = NewPermutationGenerator(b.BitmapIDRange, b.Seed)
b.ProfilePerm = NewPermutationGenerator(b.ProfileIDRange, b.Seed+1)
b.bitmapPerm = NewPermutationGenerator(b.BitmapIDRange, b.Seed)
b.profilePerm = NewPermutationGenerator(b.ProfileIDRange, b.Seed+1)
return b.HasClient.Init(hosts, agentNum)
}
@ -146,11 +146,11 @@ func (b *ZipfSetBits) Run(ctx context.Context, agentNum int) map[string]interfac
var start time.Time
for n := 0; n < b.Iterations; n++ {
// generate IDs from Zipf distribution
bitmapIDOriginal := b.BitmapRng.Uint64()
profIDOriginal := b.ProfileRng.Uint64()
bitmapIDOriginal := b.bitmapRng.Uint64()
profIDOriginal := b.profileRng.Uint64()
// permute IDs randomly, but repeatably
bitmapID := b.BitmapPerm.Next(int64(bitmapIDOriginal))
profID := b.ProfilePerm.Next(int64(profIDOriginal))
bitmapID := b.bitmapPerm.Next(int64(bitmapIDOriginal))
profID := b.profilePerm.Next(int64(profIDOriginal))
query := fmt.Sprintf("SetBit(%d, 'frame.n', %d)", b.BaseBitmapID+int64(bitmapID), b.BaseProfileID+int64(profID))
start = time.Now()