forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray_cursors.go
138 lines (116 loc) · 4.26 KB
/
array_cursors.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package internal
import "github.com/influxdata/influxdb/v2/tsdb"
var (
_ tsdb.IntegerArrayCursor = NewIntegerArrayCursorMock()
_ tsdb.FloatArrayCursor = NewFloatArrayCursorMock()
_ tsdb.UnsignedArrayCursor = NewUnsignedArrayCursorMock()
_ tsdb.StringArrayCursor = NewStringArrayCursorMock()
_ tsdb.BooleanArrayCursor = NewBooleanArrayCursorMock()
)
// ArrayCursorMock provides a mock base implementation for batch cursors.
type ArrayCursorMock struct {
CloseFn func()
ErrFn func() error
StatsFn func() tsdb.CursorStats
}
// NewArrayCursorMock returns an initialised ArrayCursorMock, which
// returns the zero value for all methods.
func NewArrayCursorMock() *ArrayCursorMock {
return &ArrayCursorMock{
CloseFn: func() {},
ErrFn: func() error { return nil },
StatsFn: func() tsdb.CursorStats { return tsdb.CursorStats{} },
}
}
// Close closes the cursor.
func (c *ArrayCursorMock) Close() { c.CloseFn() }
// Err returns the latest error, if any.
func (c *ArrayCursorMock) Err() error { return c.ErrFn() }
func (c *ArrayCursorMock) Stats() tsdb.CursorStats {
return c.StatsFn()
}
// IntegerArrayCursorMock provides a mock implementation of an IntegerArrayCursorMock.
type IntegerArrayCursorMock struct {
*ArrayCursorMock
NextFn func() *tsdb.IntegerArray
}
// NewIntegerArrayCursorMock returns an initialised IntegerArrayCursorMock, which
// returns the zero value for all methods.
func NewIntegerArrayCursorMock() *IntegerArrayCursorMock {
return &IntegerArrayCursorMock{
ArrayCursorMock: NewArrayCursorMock(),
NextFn: func() *tsdb.IntegerArray { return tsdb.NewIntegerArrayLen(0) },
}
}
// Next returns the next set of keys and values.
func (c *IntegerArrayCursorMock) Next() *tsdb.IntegerArray {
return c.NextFn()
}
// FloatArrayCursorMock provides a mock implementation of a FloatArrayCursor.
type FloatArrayCursorMock struct {
*ArrayCursorMock
NextFn func() *tsdb.FloatArray
}
// NewFloatArrayCursorMock returns an initialised FloatArrayCursorMock, which
// returns the zero value for all methods.
func NewFloatArrayCursorMock() *FloatArrayCursorMock {
return &FloatArrayCursorMock{
ArrayCursorMock: NewArrayCursorMock(),
NextFn: func() *tsdb.FloatArray { return tsdb.NewFloatArrayLen(0) },
}
}
// Next returns the next set of keys and values.
func (c *FloatArrayCursorMock) Next() *tsdb.FloatArray {
return c.NextFn()
}
// UnsignedArrayCursorMock provides a mock implementation of an UnsignedArrayCursorMock.
type UnsignedArrayCursorMock struct {
*ArrayCursorMock
NextFn func() *tsdb.UnsignedArray
}
// NewUnsignedArrayCursorMock returns an initialised UnsignedArrayCursorMock, which
// returns the zero value for all methods.
func NewUnsignedArrayCursorMock() *UnsignedArrayCursorMock {
return &UnsignedArrayCursorMock{
ArrayCursorMock: NewArrayCursorMock(),
NextFn: func() *tsdb.UnsignedArray { return tsdb.NewUnsignedArrayLen(0) },
}
}
// Next returns the next set of keys and values.
func (c *UnsignedArrayCursorMock) Next() *tsdb.UnsignedArray {
return c.NextFn()
}
// StringArrayCursorMock provides a mock implementation of a StringArrayCursor.
type StringArrayCursorMock struct {
*ArrayCursorMock
NextFn func() *tsdb.StringArray
}
// NewStringArrayCursorMock returns an initialised StringArrayCursorMock, which
// returns the zero value for all methods.
func NewStringArrayCursorMock() *StringArrayCursorMock {
return &StringArrayCursorMock{
ArrayCursorMock: NewArrayCursorMock(),
NextFn: func() *tsdb.StringArray { return tsdb.NewStringArrayLen(0) },
}
}
// Next returns the next set of keys and values.
func (c *StringArrayCursorMock) Next() *tsdb.StringArray {
return c.NextFn()
}
// BooleanArrayCursorMock provides a mock implementation of a BooleanArrayCursor.
type BooleanArrayCursorMock struct {
*ArrayCursorMock
NextFn func() *tsdb.BooleanArray
}
// NewBooleanArrayCursorMock returns an initialised BooleanArrayCursorMock, which
// returns the zero value for all methods.
func NewBooleanArrayCursorMock() *BooleanArrayCursorMock {
return &BooleanArrayCursorMock{
ArrayCursorMock: NewArrayCursorMock(),
NextFn: func() *tsdb.BooleanArray { return tsdb.NewBooleanArrayLen(0) },
}
}
// Next returns the next set of keys and values.
func (c *BooleanArrayCursorMock) Next() *tsdb.BooleanArray {
return c.NextFn()
}