forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cursor.go
71 lines (58 loc) · 1.39 KB
/
cursor.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
package tsdb
import (
"context"
"github.com/influxdata/influxdb/models"
"github.com/influxdata/influxdb/query"
)
// EOF represents a "not found" key returned by a Cursor.
const EOF = query.ZeroTime
// Cursor represents an iterator over a series.
type Cursor interface {
Close()
Err() error
}
type IntegerBatchCursor interface {
Cursor
Next() (keys []int64, values []int64)
}
type FloatBatchCursor interface {
Cursor
Next() (keys []int64, values []float64)
}
type UnsignedBatchCursor interface {
Cursor
Next() (keys []int64, values []uint64)
}
type StringBatchCursor interface {
Cursor
Next() (keys []int64, values []string)
}
type BooleanBatchCursor interface {
Cursor
Next() (keys []int64, values []bool)
}
type CursorRequest struct {
Name []byte
Tags models.Tags
Field string
Ascending bool
StartTime int64
EndTime int64
}
type CursorIterator interface {
Next(ctx context.Context, r *CursorRequest) (Cursor, error)
}
type CursorIterators []CursorIterator
func CreateCursorIterators(ctx context.Context, shards []*Shard) (CursorIterators, error) {
q := make(CursorIterators, 0, len(shards))
for _, s := range shards {
// possible errors are ErrEngineClosed or ErrShardDisabled, so we can safely skip those shards
if cq, err := s.CreateCursorIterator(ctx); cq != nil && err == nil {
q = append(q, cq)
}
}
if len(q) == 0 {
return nil, nil
}
return q, nil
}