当前位置: 首页>>代码示例>>Golang>>正文


Golang Query.A方法代码示例

本文整理汇总了Golang中ddtxn.Query.A方法的典型用法代码示例。如果您正苦于以下问题:Golang Query.A方法的具体用法?Golang Query.A怎么用?Golang Query.A使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ddtxn.Query的用法示例。


在下文中一共展示了Query.A方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
	}
}
开发者ID:ngaut,项目名称:ddtxn,代码行数:37,代码来源:buy.go

示例2: 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
//.........这里部分代码省略.........
开发者ID:ngaut,项目名称:ddtxn,代码行数:101,代码来源:rubis.go


注:本文中的ddtxn.Query.A方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。