// Calls rand 4 times func (b *Big) MakeOne(w int, local_seed *uint32, txn *ddtxn.Query) { rnd := uint64(ddtxn.RandN(local_seed, uint32(b.ni))) txn.U1 = rnd txn.U2 = (rnd * 2) % b.ni txn.U3 = (rnd * 3) % b.ni txn.U4 = (rnd * 4) % b.ni txn.U5 = (rnd * 5) % b.ni txn.U6 = (rnd * 6) % b.ni txn.U7 = (rnd) % uint64(b.np) if *incr { txn.TXN = ddtxn.BIG_INCR } else { txn.TXN = ddtxn.BIG_RW } }
func (b *Rubis) MakeOne(w int, local_seed *uint32, txn *ddtxn.Query) { x := float64(ddtxn.RandN(local_seed, 100)) if x < b.rates[0] { txn.TXN = ddtxn.RUBIS_BID //bidder := b.users[int(ddtxn.RandN(local_seed, b.sp))+w*int(b.sp)] bidder := b.users[int(ddtxn.RandN(local_seed, uint32(b.nbidders)))] //product := b.products[ddtxn.RandN(local_seed, uint32(b.nproducts))] var x uint32 if b.zipfd > 0 { x = uint32(b.zip[w].Uint64()) } else { x = ddtxn.RandN(local_seed, uint32(b.nproducts)) } product := b.products[x] txn.U1 = uint64(bidder) if product == 0 { log.Fatalf("store bid ID 0? %v %v", x, b.products[x]) } txn.U2 = uint64(product) //txn.U3 = uint64(ddtxn.RandN(local_seed, 10)) txn.U3 = uint64(time.Now().UnixNano()) & 0x000efff } else if x < b.rates[1] { txn.TXN = ddtxn.RUBIS_VIEWBIDHIST x := ddtxn.RandN(local_seed, uint32(b.nproducts)) product := b.products[x] if product == 0 { log.Fatalf("view bid hist ID 0? %v %v", x, b.products[x]) } txn.U1 = uint64(product) } else if x < b.rates[2] { txn.TXN = ddtxn.RUBIS_BUYNOW //bidder := b.users[int(ddtxn.RandN(local_seed, b.sp))+w*int(b.sp)] bidder := b.users[int(ddtxn.RandN(local_seed, uint32(b.nbidders)))] x := ddtxn.RandN(local_seed, uint32(b.nproducts)) product := b.products[x] if product == 0 { log.Fatalf("buy now ID 0? %v %v", x, b.products[x]) } txn.U1 = uint64(bidder) txn.U2 = uint64(product) txn.A = int32(ddtxn.RandN(local_seed, 10)) } else if x < b.rates[3] { txn.TXN = ddtxn.RUBIS_COMMENT // u1 := b.users[int(ddtxn.RandN(local_seed, b.sp))+w*int(b.sp)] u1 := b.users[int(ddtxn.RandN(local_seed, uint32(b.nbidders)))] // u2 := b.users[int(ddtxn.RandN(local_seed, b.sp))+w*int(b.sp)] u2 := b.users[int(ddtxn.RandN(local_seed, uint32(b.nbidders)))] x := ddtxn.RandN(local_seed, uint32(b.nproducts)) product := b.products[x] if product == 0 { log.Fatalf("comment ID 0? %v %v", x, b.products[x]) } txn.U1 = uint64(u1) txn.U2 = uint64(u2) txn.U3 = uint64(product) txn.S1 = "xxxx" txn.U4 = 1 } else if x < b.rates[4] { txn.TXN = ddtxn.RUBIS_NEWITEM // bidder := b.users[int(ddtxn.RandN(local_seed, b.sp))+w*int(b.sp)] bidder := b.users[int(ddtxn.RandN(local_seed, uint32(b.nbidders)))] amt := uint64(ddtxn.RandN(local_seed, 10)) txn.U1 = uint64(bidder) txn.S1 = "yyyy" txn.S2 = "zzzz" txn.U2 = amt txn.U3 = amt txn.U4 = amt txn.U5 = 1 txn.U6 = 1 txn.U7 = uint64(ddtxn.RandN(local_seed, uint32(ddtxn.NUM_CATEGORIES))) } else if x < b.rates[5] { txn.TXN = ddtxn.RUBIS_PUTBID x := ddtxn.RandN(local_seed, uint32(b.nproducts)) product := b.products[x] if product == 0 { log.Fatalf("put bid ID 0? %v %v", x, b.products[x]) } txn.U1 = uint64(product) } else if x < b.rates[6] { txn.TXN = ddtxn.RUBIS_PUTCOMMENT x := ddtxn.RandN(local_seed, uint32(b.nproducts)) product := b.products[x] if product == 0 { log.Fatalf("put comment ID 0? %v %v", x, b.products[x]) } // bidder := b.users[int(ddtxn.RandN(local_seed, b.sp))+w*int(b.sp)] bidder := b.users[int(ddtxn.RandN(local_seed, uint32(b.nbidders)))] txn.U1 = uint64(bidder) txn.U2 = uint64(product) } else if x < b.rates[7] { txn.TXN = ddtxn.RUBIS_REGISTER txn.U1 = uint64(ddtxn.RandN(local_seed, uint32(ddtxn.NUM_REGIONS))) txn.U2 = uint64(ddtxn.RandN(local_seed, 1000000000)) } else if x < b.rates[8] { txn.TXN = ddtxn.RUBIS_SEARCHCAT txn.U1 = uint64(ddtxn.RandN(local_seed, uint32(ddtxn.NUM_CATEGORIES))) txn.U2 = 5 } else if x < b.rates[9] { txn.TXN = ddtxn.RUBIS_SEARCHREG txn.U1 = uint64(ddtxn.RandN(local_seed, uint32(ddtxn.NUM_REGIONS))) txn.U2 = uint64(ddtxn.RandN(local_seed, uint32(ddtxn.NUM_CATEGORIES))) txn.U3 = 5 } else if x < b.rates[10] { txn.TXN = ddtxn.RUBIS_VIEW x := ddtxn.RandN(local_seed, uint32(b.nproducts)) product := b.products[x] if product == 0 { log.Fatalf("view ID 0? %v %v", x, b.products[x]) } txn.U1 = uint64(product) } else if x < b.rates[11] { txn.TXN = ddtxn.RUBIS_VIEWUSER // bidder := b.users[int(ddtxn.RandN(local_seed, b.sp))+w*int(b.sp)] bidder := b.users[int(ddtxn.RandN(local_seed, uint32(b.nbidders)))] txn.U1 = uint64(bidder) } else { log.Fatalf("No such transaction\n") } }