Skip to content

Commit

Permalink
timerseries series set: unexported types
Browse files Browse the repository at this point in the history
Signed-off-by: Thor <[email protected]>
  • Loading branch information
Thor committed Mar 6, 2020
1 parent 58dc385 commit de1ef2a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions pkg/querier/timeseries_series_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ func (t *timeSeriesSeriesSet) At() storage.Series {
if t.i < 0 {
return nil
}
return &Timeseries{series: t.ts[t.i]}
return &timeseries{series: t.ts[t.i]}
}

// Err implements SeriesSet interface
func (t *timeSeriesSeriesSet) Err() error { return nil }

// Timeseries is a type wrapper that implements the storage.Series interface
type Timeseries struct {
// timeseries is a type wrapper that implements the storage.Series interface
type timeseries struct {
series client.TimeSeries
}

// TimeSeriesSeriesIterator is a wrapper around a client.TimeSeries to implement the SeriesIterator interface
type TimeSeriesSeriesIterator struct {
ts *Timeseries
// timeSeriesSeriesIterator is a wrapper around a client.TimeSeries to implement the SeriesIterator interface
type timeSeriesSeriesIterator struct {
ts *timeseries
i int
}

Expand All @@ -58,20 +58,20 @@ func (b byTimeSeriesLabels) Less(i, j int) bool {

// Labels implements the storage.Series interface.
// Conversion is safe because ingester sets these by calling client.FromLabelsToLabelAdapters which guarantees labels are sorted.
func (t *Timeseries) Labels() labels.Labels {
func (t *timeseries) Labels() labels.Labels {
return client.FromLabelAdaptersToLabels(t.series.Labels)
}

// Iterator implements the storage.Series interface
func (t *Timeseries) Iterator() storage.SeriesIterator {
return &TimeSeriesSeriesIterator{
func (t *timeseries) Iterator() storage.SeriesIterator {
return &timeSeriesSeriesIterator{
ts: t,
i: -1,
}
}

// Seek implements SeriesIterator interface
func (t *TimeSeriesSeriesIterator) Seek(s int64) bool {
func (t *timeSeriesSeriesIterator) Seek(s int64) bool {
offset := 0
if t.i > 0 {
offset = t.i // only advance via Seek
Expand All @@ -85,15 +85,15 @@ func (t *TimeSeriesSeriesIterator) Seek(s int64) bool {
}

// At implements the SeriesIterator interface
func (t *TimeSeriesSeriesIterator) At() (int64, float64) {
func (t *timeSeriesSeriesIterator) At() (int64, float64) {
if t.i < 0 || t.i >= len(t.ts.series.Samples) {
return 0, 0
}
return t.ts.series.Samples[t.i].TimestampMs, t.ts.series.Samples[t.i].Value
}

// Next implements the SeriesIterator interface
func (t *TimeSeriesSeriesIterator) Next() bool { t.i++; return t.i < len(t.ts.series.Samples) }
func (t *timeSeriesSeriesIterator) Next() bool { t.i++; return t.i < len(t.ts.series.Samples) }

// Err implements the SeriesIterator interface
func (t *TimeSeriesSeriesIterator) Err() error { return nil }
func (t *timeSeriesSeriesIterator) Err() error { return nil }
2 changes: 1 addition & 1 deletion pkg/querier/timeseries_series_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestTimeSeriesSeriesSet(t *testing.T) {
}

func TestTimeSeriesIterator(t *testing.T) {
ts := Timeseries{
ts := timeseries{
series: client.TimeSeries{
Labels: []client.LabelAdapter{
{
Expand Down

0 comments on commit de1ef2a

Please sign in to comment.