本文整理汇总了Golang中ddtxn.Query.U3方法的典型用法代码示例。如果您正苦于以下问题:Golang Query.U3方法的具体用法?Golang Query.U3怎么用?Golang Query.U3使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ddtxn.Query
的用法示例。
在下文中一共展示了Query.U3方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: MakeOne
// 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
}
}
示例2: MakeBid
func (b *Rubis) MakeBid(w int, local_seed *uint32, txn *ddtxn.Query) {
txn.TXN = ddtxn.RUBIS_BID
bidder := b.users[0]
var x uint32
if b.zipfd > 0 {
x = uint32(b.zip[w].Uint64())
} else {
x = ddtxn.RandN(local_seed, uint32(b.nproducts))
}
if x >= uint32(len(b.products)) {
log.Fatalf("Huh %v %v %v\n", x, len(b.products), 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(time.Now().UnixNano())
}
示例3: MakeOne
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
//.........这里部分代码省略.........