Esempio n. 1
0
func runExample(client *as.Client) {
	log.Printf("Scan parallel: namespace=" + *shared.Namespace + " set=" + *shared.Set)
	recordCount := 0
	begin := time.Now()
	policy := as.NewScanPolicy()
	recordset, err := client.ScanAll(policy, *shared.Namespace, *shared.Set)
	shared.PanicOnError(err)

L:
	for {
		select {
		case rec := <-recordset.Records:
			if rec == nil {
				break L
			}
			recordCount++

			if (recordCount % 10000) == 0 {
				log.Println("Records ", recordCount)
			}
		case err := <-recordset.Errors:
			// if there was an error, stop
			shared.PanicOnError(err)
		}
	}

	end := time.Now()
	seconds := float64(end.Sub(begin)) / float64(time.Second)
	log.Println("Total records returned: ", recordCount)
	log.Println("Elapsed time: ", seconds, " seconds")
	performance := shared.Round(float64(recordCount)/float64(seconds), 0.5, 0)
	log.Println("Records/second: ", performance)
}