Skip to content

Commit

Permalink
add bitmap support
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxu19830126 committed Oct 31, 2019
1 parent 927fd59 commit 42ff789
Show file tree
Hide file tree
Showing 69 changed files with 26,215 additions and 7,509 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ DIST_DIR = $(ROOT_DIR)dist/
.PHONY: release
release: dist_dir pd cell proxy;

.PHONY: bench
bench: ; $(info ======== compiled elasticell-pd:)
env CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) go build -mod vendor -a -installsuffix cgo -o $(DIST_DIR)bench $(LD_FLAGS) $(ROOT_DIR)cmd/bench/*.go

.PHONY: pd
pd: ; $(info ======== compiled elasticell-pd:)
env CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) go build -mod vendor -a -installsuffix cgo -o $(DIST_DIR)pd $(LD_FLAGS) $(ROOT_DIR)cmd/pd/*.go
Expand Down
67 changes: 3 additions & 64 deletions cmd/bench/bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"math/rand"
_ "net/http/pprof"
"os"
"sort"
"strconv"
"strings"
"sync"
"time"
Expand All @@ -28,7 +26,6 @@ var (
writeTimeout = flag.Int("wt", 30, "The timeout for read in seconds")
connectTimeout = flag.Int("ct", 10, "The timeout for connect to server")
addrs = flag.String("addrs", "127.0.0.1:6379", "The target address.")
indexWeight = flag.String("indexWeight", "0.0,0.0", "The weight of keys which match the index definion. Supported indices are orders and books.")
)

var (
Expand All @@ -43,29 +40,6 @@ func main() {
os.Exit(1)
}

idxWeights := make([]float64, 0)
var f float64
var err error
for _, strF := range strings.Split(*indexWeight, ",") {
if f, err = strconv.ParseFloat(strF, 64); err != nil {
panic(fmt.Sprintf("failed to parse %s as float64", strF))
}
idxWeights = append(idxWeights, f)
}
idxWeightsSum = make([]uint64, len(idxWeights))
for i, f := range idxWeights {
val := uint64(f * float64(^uint64(0)))
if i != 0 {
val += idxWeightsSum[i-1]
if val < idxWeightsSum[i-1] {
//uint64 overflow
val = ^uint64(0)
}
}
idxWeightsSum[i] = val
}
fmt.Printf("idxWeights: %v, idxWeightsSum: %v\n", idxWeights, idxWeightsSum)

gCount := *con
total := *num
if total < 0 {
Expand Down Expand Up @@ -161,18 +135,10 @@ func startG(total int64, wg, complate *sync.WaitGroup, ready chan struct{}, ans
if doRead {
redis.WriteCommand(conn, "get", key)
} else {
no := sort.Search(len(idxWeightsSum), func(i int) bool { return idxWeightsSum[i] > rnd })
if no < 2 {
rnd2 := r.Uint64()
argInts := getIdxArgs(no, rnd2)
redis.WriteCommand(conn, "hmset", argInts...)
} else {
for i := 0; i < *size; i++ {
value[i] = byte((index + k) % 0xff)
}
redis.WriteCommand(conn, "set", key, value)
for i := 0; i < *size; i++ {
value[i] = byte((index + k) % 0xff)
}

redis.WriteCommand(conn, "set", key, value)
}
c--
}
Expand Down Expand Up @@ -200,33 +166,6 @@ func startG(total int64, wg, complate *sync.WaitGroup, ready chan struct{}, ans
fmt.Printf("%s sent %d reqs\n", end.Sub(start), total)
}

func getIdxArgs(no int, i uint64) (argInts []interface{}) {
var args []string
switch no {
case 0:
args = []string{
fmt.Sprintf("book_%08d", i),
"price", fmt.Sprintf("%v", 0.3+float32(i)),
"count", fmt.Sprintf("%d", i),
"author", "Mark Chen",
}
case 1:
args = []string{
fmt.Sprintf("order_%08d", i),
"product", fmt.Sprintf("%v", i),
"count", fmt.Sprintf("%d", i*2),
"description", fmt.Sprintf("order_%08d", i),
}
default:
panic(fmt.Sprintf("invalid no %v", no))
}
argInts = make([]interface{}, len(args))
for i, v := range args {
argInts[i] = v
}
return
}

type analysis struct {
sync.RWMutex
startAt time.Time
Expand Down
85 changes: 0 additions & 85 deletions cmd/proxy/cfg.json

This file was deleted.

53 changes: 0 additions & 53 deletions cmd/query/query.go

This file was deleted.

66 changes: 0 additions & 66 deletions cmd/query/query_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/fagongzi/goetty v1.3.1
github.com/fagongzi/log v0.0.0-20190424080438-6b79fa3fda5a
github.com/fagongzi/util v0.0.0-20191029074511-8ce736c4f671
github.com/fagongzi/util v0.0.0-20191031020235-c0f29a56724d
github.com/funny/slab v0.0.0-20180511031532-b1fad5e5d478 // indirect
github.com/funny/utest v0.0.0-20161029064919-43870a374500 // indirect
github.com/garyburd/redigo v1.6.0
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/gogo/protobuf v1.3.1
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
github.com/golang/protobuf v1.3.2
Expand All @@ -31,6 +30,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.11.3 // indirect
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/montanaflynn/stats v0.5.0
github.com/pilosa/pilosa v1.4.0
github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v1.2.1
Expand Down
Loading

0 comments on commit 42ff789

Please sign in to comment.