put: update

This commit is contained in:
Gyu-Ho Lee 2016-03-16 02:51:16 -07:00
parent e9b45c9d60
commit dc5dc8ff53
1 changed files with 1 additions and 7 deletions

View File

@ -18,7 +18,6 @@ import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"log" "log"
"math/rand"
"os" "os"
"time" "time"
@ -48,7 +47,6 @@ var (
keySpaceSize int keySpaceSize int
seqKeys bool seqKeys bool
uniqueKeys bool
etcdCompactionCycle int64 etcdCompactionCycle int64
) )
@ -60,7 +58,6 @@ func init() {
putCmd.Flags().IntVar(&putTotal, "total", 10000, "Total number of put requests") putCmd.Flags().IntVar(&putTotal, "total", 10000, "Total number of put requests")
putCmd.Flags().IntVar(&keySpaceSize, "key-space-size", 1, "Maximum possible keys") putCmd.Flags().IntVar(&keySpaceSize, "key-space-size", 1, "Maximum possible keys")
putCmd.Flags().BoolVar(&seqKeys, "sequential-keys", false, "Use sequential keys") putCmd.Flags().BoolVar(&seqKeys, "sequential-keys", false, "Use sequential keys")
putCmd.Flags().BoolVarP(&uniqueKeys, "unique-keys", "u", false, "Use unique keys (do not duplicate with sequential-keys)")
putCmd.Flags().Int64Var(&etcdCompactionCycle, "etcd-compaction-cycle", 0, "Compact every X number of put requests. 0 means no compaction.") putCmd.Flags().Int64Var(&etcdCompactionCycle, "etcd-compaction-cycle", 0, "Compact every X number of put requests. 0 means no compaction.")
} }
@ -129,10 +126,8 @@ func putFunc(cmd *cobra.Command, args []string) {
} }
if seqKeys { if seqKeys {
binary.PutVarint(k, int64(i%keySpaceSize)) binary.PutVarint(k, int64(i%keySpaceSize))
} else if uniqueKeys {
k = keys[i]
} else { } else {
binary.PutVarint(k, int64(rand.Intn(keySpaceSize))) k = keys[i]
} }
switch database { switch database {
case "etcd": case "etcd":
@ -176,7 +171,6 @@ func doPutZk(ctx context.Context, conn *zk.Conn, requests <-chan request) {
op := req.zkOp op := req.zkOp
st := time.Now() st := time.Now()
fmt.Println("creating", op.key)
_, err := conn.Create(op.key, op.value, zkCreateFlags, zkCreateAcl) _, err := conn.Create(op.key, op.value, zkCreateFlags, zkCreateAcl)
var errStr string var errStr string