block

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block interface {
	// StepIter returns a StepIterator
	StepIter() (StepIter, error)
	// SeriesIter returns a SeriesIterator
	SeriesIter() (SeriesIter, error)
	// Close frees up any resources
	Close() error
}

Block represents a group of series across a time bound

type Bounds

type Bounds struct {
	Start    time.Time
	End      time.Time
	StepSize time.Duration
}

Bounds are the time bounds

func (Bounds) Steps

func (b Bounds) Steps() int

Steps calculates the number of steps for the bounds

func (Bounds) String

func (b Bounds) String() string

String representation of the bounds

func (Bounds) TimeForIndex

func (b Bounds) TimeForIndex(idx int) (time.Time, error)

TimeForIndex returns the start time for a given index assuming a uniform step size

type Builder

type Builder interface {
	AppendValue(idx int, value float64) error
	Build() Block
	AddCols(num int) error
}

Builder builds a new block

func NewColumnBlockBuilder

func NewColumnBlockBuilder(meta Metadata, seriesMeta []SeriesMeta) Builder

NewColumnBlockBuilder creates a new column block builder

type ColStep

type ColStep struct {
	// contains filtered or unexported fields
}

ColStep is a single column containing data from multiple series at a given time step

func (ColStep) Time

func (c ColStep) Time() time.Time

Time for the step

func (ColStep) Values

func (c ColStep) Values() []float64

Values for the column

type ColumnBlockBuilder

type ColumnBlockBuilder struct {
	// contains filtered or unexported fields
}

ColumnBlockBuilder builds a block optimized for column iteration

func (ColumnBlockBuilder) AddCols

func (cb ColumnBlockBuilder) AddCols(num int) error

AddCols adds new columns

func (ColumnBlockBuilder) AppendValue

func (cb ColumnBlockBuilder) AppendValue(idx int, value float64) error

AppendValue adds a value to a column at index

func (ColumnBlockBuilder) Build

func (cb ColumnBlockBuilder) Build() Block

Build extracts the block TODO: Return an immutable copy

type Iterator

type Iterator interface {
	Next() bool
	Close()
}

Iterator is the base iterator

type Metadata

type Metadata struct {
	Bounds Bounds
	Tags   models.Tags // Common tags across different series
}

Metadata is metadata for a block

func (Metadata) String

func (m Metadata) String() string

String returns a string representation of metadata

type Result

type Result struct {
	Blocks []Block
}

Result is the result from a block query

type Series

type Series struct {
	Meta SeriesMeta
	// contains filtered or unexported fields
}

Series is a single series within a block

func NewSeries

func NewSeries(values []float64, meta SeriesMeta) Series

NewSeries creates a new series

func (Series) Len

func (s Series) Len() int

Len returns the number of datapoints in the series

func (Series) ValueAtStep

func (s Series) ValueAtStep(idx int) float64

ValueAtStep returns the datapoint value at a step index

func (Series) Values

func (s Series) Values() []float64

Values returns the internal values slice

type SeriesIter

type SeriesIter interface {
	Iterator
	// Current returns the current series for the block
	Current() (Series, error)
	// SeriesCount returns the number of series
	SeriesCount() int
	// SeriesMeta returns the metadata for each series in the block
	SeriesMeta() []SeriesMeta
	// Meta returns the metadata for the block
	Meta() Metadata
}

SeriesIter iterates through a block horizontally

type SeriesMeta

type SeriesMeta struct {
	Tags models.Tags
	Name string
}

SeriesMeta is metadata data for the series

type Step

type Step interface {
	Time() time.Time
	Values() []float64
}

Step is a single time step within a block

func NewColStep

func NewColStep(t time.Time, values []float64) Step

NewColStep creates a new column step

type StepIter

type StepIter interface {
	Iterator
	// Current returns the current step for the block
	Current() (Step, error)
	// StepCount returns the number of steps
	StepCount() int
	// SeriesMeta returns the metadata for each series in the block
	SeriesMeta() []SeriesMeta
	// Meta returns the metadata for the block
	Meta() Metadata
}

StepIter iterates through a block vertically

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL