Skip to content

Instantly share code, notes, and snippets.

@jwilder
Created March 11, 2016 16:26
Show Gist options
  • Save jwilder/11ea163a145ae664142c to your computer and use it in GitHub Desktop.
Save jwilder/11ea163a145ae664142c to your computer and use it in GitHub Desktop.
diff
diff --git a/coordinator/query_executor.go b/coordinator/query_executor.go
index 34ec5a4..a93680c 100644
--- a/coordinator/query_executor.go
+++ b/coordinator/query_executor.go
@@ -1076,22 +1076,6 @@ func (d *NodeDialer) DialNode(nodeID uint64) (net.Conn, error) {
return conn, nil
}
-// TSDBStore is an interface for accessing the time series data store.
-type TSDBStore interface {
- CreateShard(database, policy string, shardID uint64) error
- WriteToShard(shardID uint64, points []models.Point) error
-
- DeleteDatabase(name string) error
- DeleteMeasurement(database, name string) error
- DeleteRetentionPolicy(database, name string) error
- DeleteSeries(database string, sources []influxql.Source, condition influxql.Expr) error
- ExecuteShowFieldKeysStatement(stmt *influxql.ShowFieldKeysStatement, database string) (models.Rows, error)
- ExecuteShowSeriesStatement(stmt *influxql.ShowSeriesStatement, database string) (models.Rows, error)
- ExecuteShowTagValuesStatement(stmt *influxql.ShowTagValuesStatement, database string) (models.Rows, error)
- ExpandSources(sources influxql.Sources) (influxql.Sources, error)
- ShardIteratorCreator(id uint64) influxql.IteratorCreator
-}
-
// joinUint64 returns a comma-delimited string of uint64 numbers.
func joinUint64(a []uint64) string {
var buf bytes.Buffer
diff --git a/coordinator/query_executor_test.go b/coordinator/query_executor_test.go
index 3d0e0a9..a51659e 100644
--- a/coordinator/query_executor_test.go
+++ b/coordinator/query_executor_test.go
@@ -9,12 +9,11 @@ import (
"time"
"github.com/davecgh/go-spew/spew"
- "github.com/influxdata/influxdb"
- "github.com/influxdata/influxdb/cluster"
"github.com/influxdata/influxdb/influxql"
"github.com/influxdata/influxdb/models"
influxmeta "github.com/influxdata/influxdb/services/meta"
"github.com/influxdata/plutonium-meta"
+ "github.com/influxdata/plutonium/coordinator"
)
const (
@@ -34,31 +33,6 @@ func TestQueryExecutor_ExecuteQuery_SelectStatement(t *testing.T) {
return []influxmeta.ShardInfo{{ID: 100, Owners: []influxmeta.ShardOwner{{NodeID: 0}}}}, nil
}
- // The TSDB store should return an IteratorCreator for shard.
- // This IteratorCreator returns a single iterator with "value" in the aux fields.
- e.TSDBStore.ShardIteratorCreatorFn = func(id uint64) influxql.IteratorCreator {
- if id != 100 {
- t.Fatalf("unexpected shard id: %d", id)
- }
-
- var ic IteratorCreator
- ic.CreateIteratorFn = func(opt influxql.IteratorOptions) (influxql.Iterator, error) {
- return &FloatIterator{Points: []influxql.FloatPoint{
- {Name: "cpu", Time: int64(0 * time.Second), Aux: []interface{}{float64(100)}},
- {Name: "cpu", Time: int64(1 * time.Second), Aux: []interface{}{float64(200)}},
- }}, nil
- }
- ic.FieldDimensionsFn = func(sources influxql.Sources) (fields, dimensions map[string]struct{}, err error) {
- return map[string]struct{}{"value": struct{}{}}, nil, nil
- }
- ic.SeriesKeysFn = func(opt influxql.IteratorOptions) (influxql.SeriesList, error) {
- return influxql.SeriesList{
- {Name: "cpu", Aux: []influxql.DataType{influxql.Float}},
- }, nil
- }
- return &ic
- }
-
// Verify all results from the query.
if a := ReadAllResults(e.ExecuteQuery(`SELECT * FROM cpu`, "db0", 0)); !reflect.DeepEqual(a, []*influxql.Result{
{
@@ -104,7 +78,6 @@ func TestQueryExecutor_ExecuteQuery_SelectStatement_Remote(t *testing.T) {
// Two shards are returned. One local and one remote.
e.MetaClient.ShardsByTimeRangeFn = func(sources influxql.Sources, tmin, tmax time.Time) (a []influxmeta.ShardInfo, err error) {
return []influxmeta.ShardInfo{
- {ID: 100, Owners: []influxmeta.ShardOwner{{NodeID: 0}}},
{ID: 200, Owners: []influxmeta.ShardOwner{{NodeID: 1}}},
}, nil
}
@@ -137,19 +110,19 @@ func TestQueryExecutor_ExecuteQuery_SelectStatement_Remote(t *testing.T) {
Name: "cpu",
Columns: []string{"time", "count"},
Values: [][]interface{}{
- {time.Unix(0, 0).UTC(), float64(30)},
+ {time.Unix(0, 0).UTC(), float64(20)},
},
}},
},
}
if got := ReadAllResults(e.ExecuteQuery(`SELECT count(value) FROM cpu`, "db0", 0)); !reflect.DeepEqual(got, exp) {
- t.Fatalf("unexpected results: \n\nexp:\n%s\n\ngot:\n%s\n", spew.Sdump(got), spew.Sdump(exp))
+ t.Fatalf("unexpected results: \n\nexp:\n%s\n\ngot:\n%s\n", spew.Sdump(exp), spew.Sdump(got))
}
}
// QueryExecutor is a test wrapper for cluster.QueryExecutor.
type QueryExecutor struct {
- *cluster.QueryExecutor
+ *coordinator.QueryExecutor
MetaClient MetaClient
TSDBStore TSDBStore
@@ -160,11 +133,9 @@ type QueryExecutor struct {
// This query executor always has a node id of 0.
func NewQueryExecutor() *QueryExecutor {
e := &QueryExecutor{
- QueryExecutor: cluster.NewQueryExecutor(),
+ QueryExecutor: coordinator.NewQueryExecutor(),
}
- e.Node = &influxdb.Node{ID: 0}
e.QueryExecutor.MetaClient = &e.MetaClient
- e.QueryExecutor.TSDBStore = &e.TSDBStore
e.QueryExecutor.LogOutput = &e.LogOutput
if testing.Verbose() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment