forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resultset.go
65 lines (53 loc) · 1.12 KB
/
resultset.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
package storage
import (
"context"
"github.com/influxdata/influxdb/models"
"github.com/influxdata/influxdb/tsdb"
)
type readRequest struct {
ctx context.Context
start, end int64
asc bool
limit int64
aggregate *Aggregate
}
type multiShardCursors interface {
createCursor(row seriesRow) tsdb.Cursor
newAggregateCursor(ctx context.Context, agg *Aggregate, cursor tsdb.Cursor) tsdb.Cursor
}
type resultSet struct {
req readRequest
cur seriesCursor
row seriesRow
mb multiShardCursors
}
// Close closes the result set. Close is idempotent.
func (r *resultSet) Close() {
if r == nil {
return // Nothing to do.
}
r.row.query = nil
r.cur.Close()
}
// Next returns true if there are more results available.
func (r *resultSet) Next() bool {
if r == nil {
return false
}
row := r.cur.Next()
if row == nil {
return false
}
r.row = *row
return true
}
func (r *resultSet) Cursor() tsdb.Cursor {
cur := r.mb.createCursor(r.row)
if r.req.aggregate != nil {
cur = r.mb.newAggregateCursor(r.req.ctx, r.req.aggregate, cur)
}
return cur
}
func (r *resultSet) Tags() models.Tags {
return r.row.tags
}