diff --git a/mock/reader.go b/mock/reader.go index ac90bf2b8c..31be3e46b5 100644 --- a/mock/reader.go +++ b/mock/reader.go @@ -42,19 +42,16 @@ func (s *StorageReader) Close() { type WindowAggregateStoreReader struct { *StorageReader - HasWindowAggregateCapabilityFn func(ctx context.Context) bool + GetWindowAggregateCapabilityFn func(ctx context.Context) query.WindowAggregateCapability ReadWindowAggregateFn func(ctx context.Context, spec query.ReadWindowAggregateSpec, alloc *memory.Allocator) (query.TableIterator, error) } -func (s *WindowAggregateStoreReader) HasWindowAggregateCapability(ctx context.Context, capability ...*query.WindowAggregateCapability) bool { +func (s *WindowAggregateStoreReader) GetWindowAggregateCapability(ctx context.Context) query.WindowAggregateCapability { // Use the function if it exists. - if s.HasWindowAggregateCapabilityFn != nil { - return s.HasWindowAggregateCapabilityFn(ctx) + if s.GetWindowAggregateCapabilityFn != nil { + return s.GetWindowAggregateCapabilityFn(ctx) } - - // Provide a default implementation if one wasn't set. - // This will return true if the other function was set. - return s.ReadWindowAggregateFn != nil + return nil } func (s *WindowAggregateStoreReader) ReadWindowAggregate(ctx context.Context, spec query.ReadWindowAggregateSpec, alloc *memory.Allocator) (query.TableIterator, error) { diff --git a/query/storage.go b/query/storage.go index 9c19bb5aa7..f71a2b3044 100644 --- a/query/storage.go +++ b/query/storage.go @@ -25,14 +25,13 @@ type StorageReader interface { } // WindowAggregateCapability describes what is supported by WindowAggregateReader. -type WindowAggregateCapability struct{} +type WindowAggregateCapability interface {} // WindowAggregateReader implements the WindowAggregate capability. type WindowAggregateReader interface { - // HasWindowAggregateCapability will test if this Reader source supports the ReadWindowAggregate capability. - // If WindowAggregateCapability is passed to the method, then the struct - // is filled with a detailed list of what the RPC call supports. - HasWindowAggregateCapability(ctx context.Context, capability ...*WindowAggregateCapability) bool + // GetWindowAggregateCapability will get a detailed list of what the RPC call supports + // for window aggregate. + GetWindowAggregateCapability(ctx context.Context) WindowAggregateCapability // ReadWindowAggregate will read a table using the WindowAggregate method. ReadWindowAggregate(ctx context.Context, spec ReadWindowAggregateSpec, alloc *memory.Allocator) (TableIterator, error) diff --git a/storage/flux/reader.go b/storage/flux/reader.go index e7f17f2c8d..29f1d3bc5a 100644 --- a/storage/flux/reader.go +++ b/storage/flux/reader.go @@ -80,11 +80,11 @@ func (r *storeReader) ReadGroup(ctx context.Context, spec query.ReadGroupSpec, a }, nil } -func (r *storeReader) HasWindowAggregateCapability(ctx context.Context, capability ...*query.WindowAggregateCapability) bool { +func (r *storeReader) GetWindowAggregateCapability(ctx context.Context) query.WindowAggregateCapability { if aggStore, ok := r.s.(storage.WindowAggregateStore); ok { - return aggStore.HasWindowAggregateCapability(ctx) + return aggStore.GetWindowAggregateCapability(ctx) } - return false + return nil } func (r *storeReader) ReadWindowAggregate(ctx context.Context, spec query.ReadWindowAggregateSpec, alloc *memory.Allocator) (query.TableIterator, error) { diff --git a/storage/reads/store.go b/storage/reads/store.go index 044c54743d..ec21b4def4 100644 --- a/storage/reads/store.go +++ b/storage/reads/store.go @@ -5,6 +5,7 @@ import ( "github.com/gogo/protobuf/proto" "github.com/influxdata/influxdb/v2/models" + "github.com/influxdata/influxdb/v2/query" "github.com/influxdata/influxdb/v2/storage/reads/datatypes" "github.com/influxdata/influxdb/v2/tsdb/cursors" ) @@ -84,14 +85,15 @@ type Store interface { } // WindowAggregateCapability describes what is supported by WindowAggregateStore. -type WindowAggregateCapability struct{} +type WindowAggregateCapability interface{ + query.WindowAggregateCapability +} // WindowAggregateStore implements the WindowAggregate capability. type WindowAggregateStore interface { - // HasWindowAggregateCapability checks if this Store supports the capability. - // If WindowAggregateCapability is passed to the method, then the struct - // is filled with a detailed list of what the RPC call supports. - HasWindowAggregateCapability(ctx context.Context, capability ...*WindowAggregateCapability) bool + // GetWindowAggregateCapability will get a detailed list of what the RPC call supports + // for window aggregate. + GetWindowAggregateCapability(ctx context.Context) WindowAggregateCapability // WindowAggregate will invoke a ReadWindowAggregateRequest against the Store. WindowAggregate(ctx context.Context, req *datatypes.ReadWindowAggregateRequest) (ResultSet, error) diff --git a/storage/readservice/store.go b/storage/readservice/store.go index d39ee45a53..14fa619b75 100644 --- a/storage/readservice/store.go +++ b/storage/readservice/store.go @@ -154,8 +154,8 @@ func (s *store) GetSource(orgID, bucketID uint64) proto.Message { } } -func (s *store) HasWindowAggregateCapability(ctx context.Context, capability ...*reads.WindowAggregateCapability) bool { - return false +func (s *store) GetWindowAggregateCapability(ctx context.Context) reads.WindowAggregateCapability { + return nil } // WindowAggregate will invoke a ReadWindowAggregateRequest against the Store.