1package tsdb 2 3import ( 4 "context" 5 6 "github.com/influxdata/influxdb/models" 7 "github.com/influxdata/influxdb/query" 8) 9 10// EOF represents a "not found" key returned by a Cursor. 11const EOF = query.ZeroTime 12 13// Cursor represents an iterator over a series. 14type Cursor interface { 15 Close() 16 Err() error 17} 18 19type IntegerBatchCursor interface { 20 Cursor 21 Next() (keys []int64, values []int64) 22} 23 24type FloatBatchCursor interface { 25 Cursor 26 Next() (keys []int64, values []float64) 27} 28 29type UnsignedBatchCursor interface { 30 Cursor 31 Next() (keys []int64, values []uint64) 32} 33 34type StringBatchCursor interface { 35 Cursor 36 Next() (keys []int64, values []string) 37} 38 39type BooleanBatchCursor interface { 40 Cursor 41 Next() (keys []int64, values []bool) 42} 43 44type CursorRequest struct { 45 Name []byte 46 Tags models.Tags 47 Field string 48 Ascending bool 49 StartTime int64 50 EndTime int64 51} 52 53type CursorIterator interface { 54 Next(ctx context.Context, r *CursorRequest) (Cursor, error) 55} 56 57type CursorIterators []CursorIterator 58 59func CreateCursorIterators(ctx context.Context, shards []*Shard) (CursorIterators, error) { 60 q := make(CursorIterators, 0, len(shards)) 61 for _, s := range shards { 62 // possible errors are ErrEngineClosed or ErrShardDisabled, so we can safely skip those shards 63 if cq, err := s.CreateCursorIterator(ctx); cq != nil && err == nil { 64 q = append(q, cq) 65 } 66 } 67 if len(q) == 0 { 68 return nil, nil 69 } 70 return q, nil 71} 72