refactor(storage/readservice): rename View interface to Viewer
parent
354b58005f
commit
0f5df301ca
|
@ -24,7 +24,7 @@ var _ Engine = (*storage.Engine)(nil)
|
||||||
// to facilitate testing.
|
// to facilitate testing.
|
||||||
type Engine interface {
|
type Engine interface {
|
||||||
influxdb.DeleteService
|
influxdb.DeleteService
|
||||||
readservice.View
|
readservice.Viewer
|
||||||
storage.PointsWriter
|
storage.PointsWriter
|
||||||
storage.BucketDeleter
|
storage.BucketDeleter
|
||||||
prom.PrometheusCollector
|
prom.PrometheusCollector
|
||||||
|
|
|
@ -34,8 +34,8 @@ type indexSeriesCursor struct {
|
||||||
hasValueExpr bool
|
hasValueExpr bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newIndexSeriesCursor(ctx context.Context, src *readSource, predicate *datatypes.Predicate, view View) (*indexSeriesCursor, error) {
|
func newIndexSeriesCursor(ctx context.Context, src *readSource, predicate *datatypes.Predicate, viewer Viewer) (*indexSeriesCursor, error) {
|
||||||
queries, err := view.CreateCursorIterator(ctx)
|
queries, err := viewer.CreateCursorIterator(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ func newIndexSeriesCursor(ctx context.Context, src *readSource, predicate *datat
|
||||||
scr := storage.SeriesCursorRequest{
|
scr := storage.SeriesCursorRequest{
|
||||||
Name: tsdb.EncodeName(platform.ID(src.OrganizationID), platform.ID(src.BucketID)),
|
Name: tsdb.EncodeName(platform.ID(src.OrganizationID), platform.ID(src.BucketID)),
|
||||||
}
|
}
|
||||||
p.sqry, err = view.CreateSeriesCursor(ctx, scr, opt.Condition)
|
p.sqry, err = viewer.CreateSeriesCursor(ctx, scr, opt.Condition)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.Close()
|
p.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -17,8 +17,8 @@ import (
|
||||||
"github.com/influxdata/influxql"
|
"github.com/influxdata/influxql"
|
||||||
)
|
)
|
||||||
|
|
||||||
// View is used by the store to query data from time-series files.
|
// Viewer is used by the store to query data from time-series files.
|
||||||
type View interface {
|
type Viewer interface {
|
||||||
CreateCursorIterator(ctx context.Context) (tsdb.CursorIterator, error)
|
CreateCursorIterator(ctx context.Context) (tsdb.CursorIterator, error)
|
||||||
CreateSeriesCursor(ctx context.Context, req storage.SeriesCursorRequest, cond influxql.Expr) (storage.SeriesCursor, error)
|
CreateSeriesCursor(ctx context.Context, req storage.SeriesCursorRequest, cond influxql.Expr) (storage.SeriesCursor, error)
|
||||||
TagKeys(ctx context.Context, orgID, bucketID influxdb.ID, start, end int64, predicate influxql.Expr) (cursors.StringIterator, error)
|
TagKeys(ctx context.Context, orgID, bucketID influxdb.ID, start, end int64, predicate influxql.Expr) (cursors.StringIterator, error)
|
||||||
|
@ -26,12 +26,12 @@ type View interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type store struct {
|
type store struct {
|
||||||
view View
|
viewer Viewer
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewStore creates a store used to query time-series data.
|
// NewStore creates a store used to query time-series data.
|
||||||
func NewStore(view View) reads.Store {
|
func NewStore(viewer Viewer) reads.Store {
|
||||||
return &store{view: view}
|
return &store{viewer: viewer}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *store) ReadFilter(ctx context.Context, req *datatypes.ReadFilterRequest) (reads.ResultSet, error) {
|
func (s *store) ReadFilter(ctx context.Context, req *datatypes.ReadFilterRequest) (reads.ResultSet, error) {
|
||||||
|
@ -45,7 +45,7 @@ func (s *store) ReadFilter(ctx context.Context, req *datatypes.ReadFilterRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
var cur reads.SeriesCursor
|
var cur reads.SeriesCursor
|
||||||
if ic, err := newIndexSeriesCursor(ctx, &source, req.Predicate, s.view); err != nil {
|
if ic, err := newIndexSeriesCursor(ctx, &source, req.Predicate, s.viewer); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if ic == nil {
|
} else if ic == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -67,7 +67,7 @@ func (s *store) ReadGroup(ctx context.Context, req *datatypes.ReadGroupRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
newCursor := func() (reads.SeriesCursor, error) {
|
newCursor := func() (reads.SeriesCursor, error) {
|
||||||
cur, err := newIndexSeriesCursor(ctx, &source, req.Predicate, s.view)
|
cur, err := newIndexSeriesCursor(ctx, &source, req.Predicate, s.viewer)
|
||||||
if cur == nil || err != nil {
|
if cur == nil || err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ func (s *store) TagKeys(ctx context.Context, req *datatypes.TagKeysRequest) (cur
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return s.view.TagKeys(ctx, influxdb.ID(readSource.OrganizationID), influxdb.ID(readSource.BucketID), req.Range.Start, req.Range.End, expr)
|
return s.viewer.TagKeys(ctx, influxdb.ID(readSource.OrganizationID), influxdb.ID(readSource.BucketID), req.Range.Start, req.Range.End, expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *store) TagValues(ctx context.Context, req *datatypes.TagValuesRequest) (cursors.StringIterator, error) {
|
func (s *store) TagValues(ctx context.Context, req *datatypes.TagValuesRequest) (cursors.StringIterator, error) {
|
||||||
|
@ -156,7 +156,7 @@ func (s *store) TagValues(ctx context.Context, req *datatypes.TagValuesRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return s.view.TagValues(ctx, influxdb.ID(readSource.OrganizationID), influxdb.ID(readSource.BucketID), req.TagKey, req.Range.Start, req.Range.End, expr)
|
return s.viewer.TagValues(ctx, influxdb.ID(readSource.OrganizationID), influxdb.ID(readSource.BucketID), req.TagKey, req.Range.Start, req.Range.End, expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is easier than fooling around with .proto files.
|
// this is easier than fooling around with .proto files.
|
||||||
|
|
Loading…
Reference in New Issue