2020-04-22 21:07:45 +00:00
|
|
|
package mock
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/influxdata/flux/memory"
|
2020-04-22 21:54:09 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/query"
|
2020-04-22 21:07:45 +00:00
|
|
|
)
|
|
|
|
|
2020-04-29 15:42:16 +00:00
|
|
|
type StorageReader struct {
|
2020-10-22 21:34:22 +00:00
|
|
|
ReadFilterFn func(ctx context.Context, spec query.ReadFilterSpec, alloc *memory.Allocator) (query.TableIterator, error)
|
|
|
|
ReadGroupFn func(ctx context.Context, spec query.ReadGroupSpec, alloc *memory.Allocator) (query.TableIterator, error)
|
|
|
|
ReadTagKeysFn func(ctx context.Context, spec query.ReadTagKeysSpec, alloc *memory.Allocator) (query.TableIterator, error)
|
|
|
|
ReadTagValuesFn func(ctx context.Context, spec query.ReadTagValuesSpec, alloc *memory.Allocator) (query.TableIterator, error)
|
|
|
|
ReadWindowAggregateFn func(ctx context.Context, spec query.ReadWindowAggregateSpec, alloc *memory.Allocator) (query.TableIterator, error)
|
|
|
|
CloseFn func()
|
2020-04-22 21:07:45 +00:00
|
|
|
}
|
|
|
|
|
2020-04-29 17:02:19 +00:00
|
|
|
func (s *StorageReader) ReadFilter(ctx context.Context, spec query.ReadFilterSpec, alloc *memory.Allocator) (query.TableIterator, error) {
|
2020-04-22 21:07:45 +00:00
|
|
|
return s.ReadFilterFn(ctx, spec, alloc)
|
|
|
|
}
|
|
|
|
|
2020-04-29 17:02:19 +00:00
|
|
|
func (s *StorageReader) ReadGroup(ctx context.Context, spec query.ReadGroupSpec, alloc *memory.Allocator) (query.TableIterator, error) {
|
2020-04-22 21:07:45 +00:00
|
|
|
return s.ReadGroupFn(ctx, spec, alloc)
|
|
|
|
}
|
|
|
|
|
2020-04-29 17:02:19 +00:00
|
|
|
func (s *StorageReader) ReadTagKeys(ctx context.Context, spec query.ReadTagKeysSpec, alloc *memory.Allocator) (query.TableIterator, error) {
|
2020-04-22 21:07:45 +00:00
|
|
|
return s.ReadTagKeysFn(ctx, spec, alloc)
|
|
|
|
}
|
|
|
|
|
2020-04-29 17:02:19 +00:00
|
|
|
func (s *StorageReader) ReadTagValues(ctx context.Context, spec query.ReadTagValuesSpec, alloc *memory.Allocator) (query.TableIterator, error) {
|
2020-04-22 21:07:45 +00:00
|
|
|
return s.ReadTagValuesFn(ctx, spec, alloc)
|
|
|
|
}
|
|
|
|
|
2020-04-29 15:42:16 +00:00
|
|
|
func (s *StorageReader) Close() {
|
2020-04-22 21:07:45 +00:00
|
|
|
// Only invoke the close function if it is set.
|
|
|
|
// We want this to be a no-op and work without
|
|
|
|
// explicitly setting up a close function.
|
|
|
|
if s.CloseFn != nil {
|
|
|
|
s.CloseFn()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-22 21:34:22 +00:00
|
|
|
func (s *StorageReader) ReadWindowAggregate(ctx context.Context, spec query.ReadWindowAggregateSpec, alloc *memory.Allocator) (query.TableIterator, error) {
|
2020-04-22 21:07:45 +00:00
|
|
|
return s.ReadWindowAggregateFn(ctx, spec, alloc)
|
|
|
|
}
|