Skip to content

Instantly share code, notes, and snippets.

@c4pt0r
Created November 5, 2015 04:50
Show Gist options
  • Save c4pt0r/82a592c4a101eb4b0ed6 to your computer and use it in GitHub Desktop.
Save c4pt0r/82a592c4a101eb4b0ed6 to your computer and use it in GitHub Desktop.
func main() {
ts := time.Now()
prefix := fmt.Sprintf("%ld", ts.UnixNano())
var err error
cli, err = hbase.NewClient([]string{"localhost"}, "/hbase")
if err != nil {
panic(err)
}
dropTable(benchTbl)
createTable(benchTbl)
go func() {
log.Error(http.ListenAndServe("localhost:8889", nil))
}()
ct := time.Now()
wg := &sync.WaitGroup{}
for j := 0; j < 1000; j++ {
wg.Add(1)
go func(j int) {
defer wg.Done()
for i := 0; i < 100; i++ {
p := hbase.NewPut([]byte(fmt.Sprintf("row_%s_%d_%d", prefix, i, j)))
// 只有一个 qualifier
p.AddStringValue("cf", "q", "val_"+strconv.Itoa(i*j))
_, err := cli.Put(benchTbl, p)
if err != nil {
log.Error(err)
return
}
}
}(j)
}
wg.Wait()
elapsed := time.Since(ct)
log.Errorf("took %s", elapsed)
}
@c4pt0r
Copy link
Author

c4pt0r commented Nov 5, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment