-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
reader.go
56 lines (45 loc) · 2.55 KB
/
reader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package mock
import (
"context"
"github.com/influxdata/flux/memory"
"github.com/influxdata/influxdb/v2/query"
)
type StorageReader struct {
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)
ReadSeriesCardinalityFn func(ctx context.Context, spec query.ReadSeriesCardinalitySpec, alloc memory.Allocator) (query.TableIterator, error)
SupportReadSeriesCardinalityFn func(ctx context.Context) bool
CloseFn func()
}
func (s *StorageReader) ReadFilter(ctx context.Context, spec query.ReadFilterSpec, alloc memory.Allocator) (query.TableIterator, error) {
return s.ReadFilterFn(ctx, spec, alloc)
}
func (s *StorageReader) ReadGroup(ctx context.Context, spec query.ReadGroupSpec, alloc memory.Allocator) (query.TableIterator, error) {
return s.ReadGroupFn(ctx, spec, alloc)
}
func (s *StorageReader) ReadTagKeys(ctx context.Context, spec query.ReadTagKeysSpec, alloc memory.Allocator) (query.TableIterator, error) {
return s.ReadTagKeysFn(ctx, spec, alloc)
}
func (s *StorageReader) ReadTagValues(ctx context.Context, spec query.ReadTagValuesSpec, alloc memory.Allocator) (query.TableIterator, error) {
return s.ReadTagValuesFn(ctx, spec, alloc)
}
func (s *StorageReader) ReadSeriesCardinality(ctx context.Context, spec query.ReadSeriesCardinalitySpec, alloc memory.Allocator) (query.TableIterator, error) {
return s.ReadSeriesCardinalityFn(ctx, spec, alloc)
}
func (s *StorageReader) SupportReadSeriesCardinality(ctx context.Context) bool {
return s.SupportReadSeriesCardinalityFn(ctx)
}
func (s *StorageReader) Close() {
// 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()
}
}
func (s *StorageReader) ReadWindowAggregate(ctx context.Context, spec query.ReadWindowAggregateSpec, alloc memory.Allocator) (query.TableIterator, error) {
return s.ReadWindowAggregateFn(ctx, spec, alloc)
}