2019-04-04 15:55:09 +00:00
|
|
|
package reads
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/influxdata/influxdb/models"
|
|
|
|
"github.com/influxdata/influxdb/tsdb/cursors"
|
|
|
|
)
|
|
|
|
|
|
|
|
type multiShardCursors interface {
|
|
|
|
createCursor(row SeriesRow) cursors.Cursor
|
|
|
|
}
|
|
|
|
|
|
|
|
type resultSet struct {
|
2021-03-31 17:51:37 +00:00
|
|
|
ctx context.Context
|
|
|
|
seriesCursor SeriesCursor
|
|
|
|
seriesRow SeriesRow
|
|
|
|
arrayCursors multiShardCursors
|
2019-04-04 15:55:09 +00:00
|
|
|
}
|
|
|
|
|
fix(storage): cursor requests are [start, stop] instead of [start, stop) (#21347)
* fix: backport tsdb fix for window pushdowns
From https://github.com/influxdata/influxdb/pull/19855
* fix(storage): cursor requests are [start, stop] instead of [start, stop)
The cursors were previously [start, stop) to be consistent with how flux
requests data, but the underlying storage file store was [start, stop]
because that's how influxql read data. This reverts back the cursor
behavior so that it is now [start, stop] everywhere and the conversion
from [start, stop) to [start, stop] is performed when doing the cursor
request to get the next cursor.
cherry-pick from #21318
Co-authored-by: Sam Arnold <sarnold@influxdata.com>
(cherry picked from commit 776667279733519972dbc27fe559c1d8ffd5864a)
* chore: fix formatting
Co-authored-by: Jonathan A. Sternberg <jonathan@influxdata.com>
2021-04-30 19:26:31 +00:00
|
|
|
// TODO(jsternberg): The range is [start, end) for this function which is consistent
|
|
|
|
// with the documented interface for datatypes.ReadFilterRequest. This function should
|
|
|
|
// be refactored to take in a datatypes.ReadFilterRequest similar to the other
|
|
|
|
// ResultSet functions.
|
2021-03-31 17:51:37 +00:00
|
|
|
func NewFilteredResultSet(ctx context.Context, start, end int64, seriesCursor SeriesCursor) ResultSet {
|
2019-04-04 15:55:09 +00:00
|
|
|
return &resultSet{
|
2021-03-31 17:51:37 +00:00
|
|
|
ctx: ctx,
|
|
|
|
seriesCursor: seriesCursor,
|
|
|
|
arrayCursors: newMultiShardArrayCursors(ctx, start, end, true),
|
2019-04-04 15:55:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *resultSet) Err() error { return nil }
|
|
|
|
|
|
|
|
// Close closes the result set. Close is idempotent.
|
|
|
|
func (r *resultSet) Close() {
|
|
|
|
if r == nil {
|
|
|
|
return // Nothing to do.
|
|
|
|
}
|
2021-03-31 17:51:37 +00:00
|
|
|
r.seriesRow.Query = nil
|
|
|
|
r.seriesCursor.Close()
|
2019-04-04 15:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Next returns true if there are more results available.
|
|
|
|
func (r *resultSet) Next() bool {
|
|
|
|
if r == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-03-31 17:51:37 +00:00
|
|
|
seriesRow := r.seriesCursor.Next()
|
|
|
|
if seriesRow == nil {
|
2019-04-04 15:55:09 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-03-31 17:51:37 +00:00
|
|
|
r.seriesRow = *seriesRow
|
2019-04-04 15:55:09 +00:00
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *resultSet) Cursor() cursors.Cursor {
|
2021-03-31 17:51:37 +00:00
|
|
|
return r.arrayCursors.createCursor(r.seriesRow)
|
2019-04-04 15:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *resultSet) Tags() models.Tags {
|
2021-03-31 17:51:37 +00:00
|
|
|
return r.seriesRow.Tags
|
2019-04-04 15:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stats returns the stats for the underlying cursors.
|
|
|
|
// Available after resultset has been scanned.
|
2021-03-31 17:51:37 +00:00
|
|
|
func (r *resultSet) Stats() cursors.CursorStats { return r.seriesRow.Query.Stats() }
|