本文整理汇总了Golang中github.com/prataprc/golib/llrb.MemStore类的典型用法代码示例。如果您正苦于以下问题:Golang MemStore类的具体用法?Golang MemStore怎么用?Golang MemStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MemStore类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: validateEqual
func validateEqual(d *llrb.Dict, rb llrb.MemStore) {
refKeys := make([]*llrb.KeyInt, 0)
fmt.Printf("number of elements {dict: %v, api:%v}\n", d.Len(), rb.Len())
rb.Range(nil, nil, "both", func(k llrb.Item) bool {
refKeys = append(refKeys, k.(*llrb.KeyInt))
return true
})
keys := make([]*llrb.KeyInt, 0)
d.Range(nil, nil, "both", func(k llrb.Item) bool {
keys = append(keys, k.(*llrb.KeyInt))
return true
})
if reflect.DeepEqual(refKeys, keys) == false {
log.Fatalf("final Dict keys and LLRB keys mismatch\n")
}
}
示例2: benchDelete
func benchDelete(s llrb.MemStore) {
for _, key := range delInts {
s.Delete(key)
}
}
示例3: validate
func validate(
d *llrb.Dict,
rb llrb.MemStore, cmd []interface{}, stats map[string]int) map[string]int {
var ref, val interface{}
name := cmd[0].(string)
switch name {
case "get":
ref = d.Get(&llrb.KeyInt{int64(cmd[1].(float64)), -1})
val = rb.Get(&llrb.KeyInt{int64(cmd[1].(float64)), -1})
case "min":
ref = d.Min()
val = rb.Min()
case "max":
ref = d.Max()
val = rb.Max()
case "delmin":
ref = d.DeleteMin()
val = rb.DeleteMin()
case "delmax":
ref = d.DeleteMax()
val = rb.DeleteMax()
case "upsert":
now := time.Now().UnixNano()
k := &llrb.KeyInt{int64(cmd[1].(float64)), now}
ref = d.Upsert(k)
val = rb.Upsert(k)
case "insert":
now := time.Now().UnixNano()
k := &llrb.KeyInt{int64(cmd[1].(float64)), now}
if rb.Get(k) == nil {
d.Insert(k)
rb.Insert(k)
} else {
cmd[0] = "upsert"
ref = d.Upsert(k)
val = rb.Upsert(k)
}
case "delete":
ref = d.Delete(&llrb.KeyInt{int64(cmd[1].(float64)), -1})
val = rb.Delete(&llrb.KeyInt{int64(cmd[1].(float64)), -1})
default:
log.Fatalf("unknown command %v\n", cmd)
return stats
}
if reflect.DeepEqual(ref, val) == false {
log.Fatalf("expected %v got %v\n", ref, val)
}
stats = compute_stats(cmd, stats)
return stats
}
示例4: benchRange
func benchRange(s llrb.MemStore) {
for i := 0; i < options.bcount; i++ {
s.Range(nil, nil, "both", nil)
}
}
示例5: benchGet
func benchGet(s llrb.MemStore) {
for _, key := range getInts {
s.Get(key)
}
}
示例6: benchUpsert
func benchUpsert(s llrb.MemStore) {
for _, key := range upsInts {
s.Upsert(key)
}
}
示例7: benchInsert
func benchInsert(s llrb.MemStore) {
for _, key := range insInts {
s.Insert(key)
}
}
示例8: benchMax
func benchMax(s llrb.MemStore) {
for i := 0; i < options.bcount; i++ {
s.Max()
}
}