mgots

package module
v0.0.0-...-309cb49 Latest Latest
Warning

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

Go to latest
Published: May 31, 2015 License: MIT Imports: 6 Imported by: 0

README

mgots - Mango TS Build Status

A Time Series data model API for Go and MongoDB

Mango TS is a Google Go package built on the mgo package which implements an optimized model for periodic and nonperiodic Time Series data stored in MongoDB.

Time series data

From Wikipedia:

A time series is a sequence of data points, typically consisting of successive measurements made over a time interval.

Periodic data

Period data appears in cronological order, at regular, predefined intervals.

Examples:

  • Performance monitoring metrics every minute
  • Scheduled tasks every hour

Periodic data is arrange into pages, each representing a linear segment of time, with a slot preallocated for each expected data point. For example, if the data interval is one minute and the page size is one hour, each page will contain 60 preallocated slots; one for each minute of the hour.

The model implemented in mgots is loosely based on Sandeep Parikh's time series schema design.

Nonperiodic data

Nonperiodic data appears in cronological order, but at irregular intervals. The data model used for periodic data is not appropriate for datasets of this kind as a significant amount of storage is wasted on preallocated intervals for which no data is entered.

Examples:

  • Monitoring events at random
  • User transactions at random

Nonperiodic data is arranged into a page until a configurable page size is exhausted (E.g. 4096 bytes) when a new page is allocated. Each page represents a linear segment of time, starting from the last entry point in the previous page, until the first entry point of the next page.

The model implemented in mgots is loosely based on Sylvain Wallez's model used in Actoboard.

Page sizes

A number of facters contribute to optimizing page sizes. These include but are no limited to:

  • Disk alignment
  • Alignment in memory of memory-mapped storage
  • MongoDB's Power of 2 allocation strategy
  • Memory consumption and network utilization when querying pages and returning data

Documentation

Index

Constants

View Source
const (
	PAGE_HEADER_SIZE = 110 // page header size in bytes (as per Object.bsonsize())
	TIMESTAMP_SIZE   = 66  // Timestamp data type size in bytes (including encapsulation)
)

Variables

View Source
var ErrDuplicateSeries = errors.New("Time series already exists with the specified ID")
View Source
var ErrInvalidPageSize = errors.New("Pages size must be greater than 256 bytes")
View Source
var ErrNoData = errors.New("No existing data to update")
View Source
var ErrSeriesNotFound = errors.New("Series not found with the specified collection")

Errors

View Source
var ErrTooOld = errors.New("The timestamp of the specified value is older than the most recent entry or the series does not exist.")
View Source
var ErrValueTooLarge = errors.New("The size value specified exceeds the maximum Time Series page size.")

Functions

func BSONSize

func BSONSize(v interface{}) int

Types

type Collection

type Collection interface {
	CreateSeries(seriesId interface{}, startTime time.Time) error
	Append(seriesId interface{}, timestamp time.Time, value interface{}) error
	Update(seriedId interface{}, value interface{}) error
	Range(seriesId interface{}, minTime time.Time, maxTime time.Time) (DataPoints, error)
	Latest(seriesId interface{}) (DataPoint, error)
}

func NewNonperiodicCollection

func NewNonperiodicCollection(database *mgo.Database, name string, pageSize int) (Collection, error)

type DataPoint

type DataPoint interface {
	Timestamp() time.Time
	GetValue(v interface{}) error
}

type DataPoints

type DataPoints []DataPoint

type NonperiodicCollection

type NonperiodicCollection struct {
	PageSize int
	// contains filtered or unexported fields
}

func (*NonperiodicCollection) Append

func (c *NonperiodicCollection) Append(seriesId interface{}, timestamp time.Time, value interface{}) error

* value must have a consistent size

func (*NonperiodicCollection) CreateSeries

func (c *NonperiodicCollection) CreateSeries(seriesId interface{}, startTime time.Time) error

func (*NonperiodicCollection) Latest

func (c *NonperiodicCollection) Latest(seriesId interface{}) (DataPoint, error)

func (*NonperiodicCollection) Range

func (c *NonperiodicCollection) Range(seriesId interface{}, minTime time.Time, maxTime time.Time) (DataPoints, error)

func (*NonperiodicCollection) Update

func (c *NonperiodicCollection) Update(seriesId interface{}, value interface{}) error

Jump to

Keyboard shortcuts

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