本文整理汇总了Golang中github.com/THE108/aerospike-client-go.Client.ScanNode方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.ScanNode方法的具体用法?Golang Client.ScanNode怎么用?Golang Client.ScanNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/THE108/aerospike-client-go.Client
的用法示例。
在下文中一共展示了Client.ScanNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runExample
func runExample(client *as.Client) {
log.Println("Scan series: namespace=", *shared.Namespace, " set=", *shared.Set)
// Use low scan priority. This will take more time, but it will reduce
// the load on the server.
policy := as.NewScanPolicy()
policy.MaxRetries = 1
policy.Priority = as.LOW
nodeList := client.GetNodes()
begin := time.Now()
for _, node := range nodeList {
log.Println("Scan node ", node.GetName())
recordset, err := client.ScanNode(policy, node, *shared.Namespace, *shared.Set)
shared.PanicOnError(err)
L:
for {
select {
case rec := <-recordset.Records:
if rec == nil {
break L
}
metrics, exists := setMap[rec.Key.SetName()]
if !exists {
metrics = Metrics{}
}
metrics.count++
metrics.total++
setMap[rec.Key.SetName()] = metrics
case err := <-recordset.Errors:
// if there was an error, stop
shared.PanicOnError(err)
}
}
for k, v := range setMap {
log.Println("Node ", node, " set ", k, " count: ", v.count)
v.count = 0
}
}
end := time.Now()
seconds := float64(end.Sub(begin)) / float64(time.Second)
log.Println("Elapsed time: ", seconds, " seconds")
total := 0
for k, v := range setMap {
log.Println("Total set ", k, " count: ", v.total)
total += v.total
}
log.Println("Grand total: ", total)
performance := shared.Round(float64(total)/seconds, 0.5, 0)
log.Println("Records/second: ", performance)
}