move ExecuteQuery to client that every other benchmark can use

This commit is contained in:
Linh Vo 2017-01-27 12:13:17 -06:00
parent 743706858b
commit 602a34ef6e
2 changed files with 12 additions and 11 deletions

View file

@ -2,8 +2,9 @@ package bench
import (
"fmt"
"github.com/pilosa/pilosa"
"context"
"errors"
)
func firstHostClient(hosts []string) (*pilosa.Client, error) {
@ -56,4 +57,14 @@ func (h *HasClient) Init(hosts []string, agentNum int) error {
}
}
func (h *HasClient) ExecuteQuery(contentType, db, query string, ctx context.Context) (interface{}, error) {
if contentType == "protobuf" {
return h.client.ExecuteQuery(ctx, db, query, true)
} else if contentType == "pql" {
return h.client.ExecutePQL(ctx, db, query)
} else {
return nil, errors.New("unsupport content type")
}
}

View file

@ -7,7 +7,6 @@ import (
"io/ioutil"
"strings"
"time"
"errors"
)
// RandomQuery queries randomly and deterministically based on a seed.
@ -119,12 +118,3 @@ func (b *RandomQuery) Run(ctx context.Context) map[string]interface{} {
return results
}
func (b *RandomQuery) ExecuteQuery(contentType, db, query string, ctx context.Context, ) (interface{}, error) {
if contentType == "protobuf" {
return b.client.ExecuteQuery(ctx, db, query, true)
} else if contentType == "pql" {
return b.client.ExecutePQL(ctx, db, query)
} else {
return nil, errors.New("unsupport content type")
}
}