本文整理汇总了Golang中ddtxn.Query.K2方法的典型用法代码示例。如果您正苦于以下问题:Golang Query.K2方法的具体用法?Golang Query.K2怎么用?Golang Query.K2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ddtxn.Query
的用法示例。
在下文中一共展示了Query.K2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: MakeOne
// Calls rand 4 times
func (b *Buy) MakeOne(w int, local_seed *uint32, sp uint32, txn *ddtxn.Query) {
var bidder int
var product int
if *partition {
rnd := ddtxn.RandN(local_seed, sp/8)
lb := int(rnd)
bidder = lb + w*int(sp)
} else {
bidder = int(ddtxn.RandN(local_seed, uint32(b.nbidders)))
}
x := int(ddtxn.RandN(local_seed, 100))
if b.zipfd > 0 {
product = int(b.z[w].Uint64())
} else {
product = int(ddtxn.RandN(local_seed, uint32(b.nproducts)))
}
if x < b.read_rate {
if x > b.ncontended_rate {
// Contended read; use Zipfian distribution or np
txn.K1 = ddtxn.UserKey(uint64(bidder))
txn.K2 = ddtxn.ProductKey(product)
} else {
// (Hopefully) uncontended read. Random product.
product = int(ddtxn.RandN(local_seed, uint32(b.nbidders)))
txn.K1 = ddtxn.UserKey(uint64(bidder))
txn.K2 = ddtxn.ProductKey(product)
}
txn.TXN = ddtxn.D_READ_TWO
} else {
amt := int32(ddtxn.RandN(local_seed, 10))
txn.K1 = ddtxn.UserKey(uint64(bidder))
txn.K2 = ddtxn.ProductKey(product)
txn.A = amt
txn.TXN = ddtxn.D_BUY
}
}