models

package
v0.10.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Maximum time that can be represented via int64 nanoseconds since the epoch.
	MaxNanoTime = time.Unix(0, math.MaxInt64).UTC()
	// Minumum time that can be represented via int64 nanoseconds since the epoch.
	MinNanoTime = time.Unix(0, math.MinInt64).UTC()

	// The time is out of the representable range using int64 nanoseconds since the epoch.
	ErrTimeOutOfRange = fmt.Errorf("time outside range %s - %s", MinNanoTime, MaxNanoTime)
)

Functions

func CheckTime added in v0.10.0

func CheckTime(t time.Time) error

Check that a time is within the safe range.

func GetPrecisionMultiplier added in v0.10.0

func GetPrecisionMultiplier(precision string) int64

GetPrecisionMultiplier will return a multiplier for the precision specified

func MakeKey

func MakeKey(name []byte, tags Tags) []byte

MakeKey creates a key for a set of tags.

func SafeCalcTime added in v0.10.0

func SafeCalcTime(timestamp int64, precision string) (time.Time, error)

Safely calculate the time given. Will return error if the time is outside the supported range.

Types

type Fields

type Fields map[string]interface{}

Fields represents a mapping between a Point's field names and their values.

func (Fields) MarshalBinary

func (p Fields) MarshalBinary() []byte

MarshalBinary encodes all the fields to their proper type and returns the binary represenation NOTE: uint64 is specifically not supported due to potential overflow when we decode again later to an int64

type Point

type Point interface {
	Name() string
	SetName(string)

	Tags() Tags
	AddTag(key, value string)
	SetTags(tags Tags)

	Fields() Fields
	AddField(name string, value interface{})

	Time() time.Time
	SetTime(t time.Time)
	UnixNano() int64

	HashID() uint64
	Key() []byte

	Data() []byte
	SetData(buf []byte)

	// String returns a string representation of the point, if there is a
	// timestamp associated with the point then it will be specified with the default
	// precision of nanoseconds
	String() string

	// Bytes returns a []byte representation of the point similar to string.
	MarshalBinary() ([]byte, error)

	// PrecisionString returns a string representation of the point, if there
	// is a timestamp associated with the point then it will be specified in the
	// given unit
	PrecisionString(precision string) string

	// RoundedString returns a string representation of the point, if there
	// is a timestamp associated with the point, then it will be rounded to the
	// given duration
	RoundedString(d time.Duration) string
}

Point defines the values that will be written to the database

func MustNewPoint

func MustNewPoint(name string, tags Tags, fields Fields, time time.Time) Point

MustNewPoint returns a new point with the given measurement name, tags, fields and timestamp. If an unsupported field value (NaN) is passed, this function panics.

func NewPoint

func NewPoint(name string, tags Tags, fields Fields, time time.Time) (Point, error)

NewPoint returns a new point with the given measurement name, tags, fields and timestamp. If an unsupported field value (NaN) or out of range time is passed, this function returns an error.

func NewPointFromBytes added in v0.9.6

func NewPointFromBytes(b []byte) (Point, error)

func ParsePoints

func ParsePoints(buf []byte) ([]Point, error)

ParsePoints returns a slice of Points from a text representation of a point with each point separated by newlines. If any points fail to parse, a non-nil error will be returned in addition to the points that parsed successfully.

func ParsePointsString

func ParsePointsString(buf string) ([]Point, error)

ParsePointsString is identical to ParsePoints but accepts a string buffer.

func ParsePointsWithPrecision

func ParsePointsWithPrecision(buf []byte, defaultTime time.Time, precision string) ([]Point, error)

ParsePointsWithPrecision is similar to ParsePoints, but allows the caller to provide a precision for time.

type Points

type Points []Point

Points represents a sortable list of points by timestamp.

func (Points) Len

func (a Points) Len() int

func (Points) Less

func (a Points) Less(i, j int) bool

func (Points) Swap

func (a Points) Swap(i, j int)

type Row

type Row struct {
	Name    string            `json:"name,omitempty"`
	Tags    map[string]string `json:"tags,omitempty"`
	Columns []string          `json:"columns,omitempty"`
	Values  [][]interface{}   `json:"values,omitempty"`
	Err     error             `json:"err,omitempty"`
}

Row represents a single row returned from the execution of a statement.

func (*Row) SameSeries

func (r *Row) SameSeries(o *Row) bool

SameSeries returns true if r contains values for the same series as o.

type Rows

type Rows []*Row

Rows represents a collection of rows. Rows implements sort.Interface.

func (Rows) Len

func (p Rows) Len() int

func (Rows) Less

func (p Rows) Less(i, j int) bool

func (Rows) Swap

func (p Rows) Swap(i, j int)

type Tags

type Tags map[string]string

Tags represents a mapping between a Point's tag names and their values.

func ParseKey added in v0.9.6

func ParseKey(buf string) (string, Tags, error)

func (Tags) HashKey

func (t Tags) HashKey() []byte

HashKey hashes all of a tag's keys.

Jump to

Keyboard shortcuts

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