Skip to content

Commit

Permalink
perf(storage): expose ability to peek on stream readers
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeMac committed Sep 4, 2019
1 parent 20f717d commit 3f0d3e9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
1. [14631](https://github.com/influxdata/influxdb/pull/14631): Updated name of Local Metrics template
1. [14631](https://github.com/influxdata/influxdb/pull/14631): Dashboards for all Telegraf config bundles now created
1. [14694](https://github.com/influxdata/influxdb/pull/14694): Add ability to find tasks by name.
1. [14901](https://github.com/influxdata/influxdb/pull/14901): Add ability to Peek() on reads package StreamReader types.

### UI Improvements
1. [14917](https://github.com/influxdata/influxdb/pull/14917): Make first steps in Monitoring & Alerting more obvious
Expand Down
12 changes: 12 additions & 0 deletions storage/reads/stream_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ func (r *ResultSetStreamReader) Stats() cursors.CursorStats {
return r.fr.stats.Stats()
}

// Peek reads the next frame on the underlying stream-reader
// if there is one
func (r *ResultSetStreamReader) Peek() {
r.fr.peekFrame()
}

func (r *ResultSetStreamReader) Next() bool {
if r.fr.state == stateReadSeries {
return r.readSeriesFrame()
Expand Down Expand Up @@ -177,6 +183,12 @@ func NewGroupResultSetStreamReader(stream StreamReader) *GroupResultSetStreamRea

func (r *GroupResultSetStreamReader) Err() error { return r.fr.err }

// Peek reads the next frame on the underlying stream-reader
// if there is one
func (r *GroupResultSetStreamReader) Peek() {
r.fr.peekFrame()
}

func (r *GroupResultSetStreamReader) Next() GroupCursor {
if r.fr.state == stateReadGroup {
return r.readGroupFrame()
Expand Down
8 changes: 8 additions & 0 deletions storage/reads/stream_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ series: _m=cpu,tag0=val1
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rs := reads.NewResultSetStreamReader(tt.stream)

// ensure a peek doesn't effect the end result
rs.Peek()

sb := new(strings.Builder)
ResultSetToString(sb, rs)

Expand Down Expand Up @@ -582,6 +586,10 @@ group:
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rs := reads.NewGroupResultSetStreamReader(tt.stream)

// ensure a peek doesn't effect the end result
rs.Peek()

sb := new(strings.Builder)
GroupResultSetToString(sb, rs)

Expand Down

0 comments on commit 3f0d3e9

Please sign in to comment.