terrace

package module
v0.0.0-...-f6c54b7 Latest Latest
Warning

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

Go to latest
Published: May 23, 2019 License: AGPL-3.0 Imports: 8 Imported by: 1

README

Terrace

Terrace is a storage format for JSON events.


GoDoc CircleCI


Background

See https://misfra.me/2018/08/05/terrace/.

License

AGPL 3.0 (see LICENSE)

Documentation

Index

Constants

View Source
const (
	// CostLevel is the cost for a level access.
	CostLevel = 10
	// CostEvent is the cost for an event access.
	CostEvent = 100
)
View Source
const (
	CostTypeAccess = iota
	CostTypeSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnRange

type ColumnRange interface {
	Contains(v interface{}) bool
	// Whether this range represents a single value
	Single() bool
	MinValue() interface{}
}

ColumnRange represents a range of values for a column.

type Constraint

type Constraint struct {
	Column   string             `json:"column"`
	Operator ConstraintOperator `json:"operator"`
	Value    interface{}        `json:"value"`
}

Constraint represents a constraint for a particular column.

type ConstraintOperator

type ConstraintOperator string

ConstraintOperator represents a constraint operator.

const (
	// ConstraintOperatorEquals is an equals operator.
	ConstraintOperatorEquals ConstraintOperator = "="
	// ConstraintOperatorNotEquals is a not equals operator.
	ConstraintOperatorNotEquals = "!="
)

type ConstraintSet

type ConstraintSet map[string][]Constraint

ConstraintSet is a set of constraints for a number of columns.

func (ConstraintSet) CheckLevel

func (cs ConstraintSet) CheckLevel(level *Level) bool

CheckLevel returns false if the level doesn't meet the constraints in the ConstraintSet.

type Event

type Event map[string]interface{}

Event represents an event.

func (Event) CloneWithout

func (e Event) CloneWithout(field string) Event

CloneWithout clones an event without a field.

func (Event) Fields

func (e Event) Fields() []string

Fields returns a slice of fields within this event.

func (Event) Get

func (e Event) Get(field string) (interface{}, bool)

Get gets the value for field from the event. False is returned if the field doesn't exist.

type FloatColumnRange

type FloatColumnRange struct {
	Min float64 `json:"min"`
	Max float64 `json:"max"`
}

FloatColumnRange is a float64 column range.

func (FloatColumnRange) Contains

func (r FloatColumnRange) Contains(v interface{}) bool

Contains returns true if the range may contain v.

func (FloatColumnRange) MinValue

func (r FloatColumnRange) MinValue() interface{}

MinValue returns the min value in the range (inclusive).

func (FloatColumnRange) Single

func (r FloatColumnRange) Single() bool

Single returns true if the range represents a single value.

type IntegerColumnRange

type IntegerColumnRange struct {
	Min int `json:"min"`
	Max int `json:"max"`
}

IntegerColumnRange is an int column range.

func (IntegerColumnRange) Contains

func (r IntegerColumnRange) Contains(v interface{}) bool

Contains returns true if the range may contain v.

func (IntegerColumnRange) MinValue

func (r IntegerColumnRange) MinValue() interface{}

MinValue returns the min value in the range (inclusive).

func (IntegerColumnRange) Single

func (r IntegerColumnRange) Single() bool

Single returns true if the range represents a single value.

type JSONColumnRange

type JSONColumnRange struct {
	Type string      `json:"type"`
	Min  interface{} `json:"min"`
	Max  interface{} `json:"max"`
}

type Level

type Level struct {
	// Column this level splits on
	Column string `json:"column,omitempty"`
	// Range of values covered by this level
	Range          JSONColumnRange        `json:"range,omitempty"`
	InternalRange  ColumnRange            `json:"-"`
	SublevelColumn string                 `json:"sublevel_column,omitempty"`
	Sublevels      []*Level               `json:"sublevels,omitempty"`
	Events         []Event                `json:"events,omitempty"`
	Fixed          map[string]interface{} `json:"fixed,omitempty"`
	Count          int                    `json:"count"`
	Sums           map[string]float64     `json:"sums,omitempty"`
}

Level is a Terrace level.

func Generate

func Generate(logger *log.Logger, events []Event, constraints []ConstraintSet, opts Options) (*Level, error)

Generate generates a Level.

func (*Level) NewCursor

func (l *Level) NewCursor() (query.Cursor, error)

func (*Level) Push

func (l *Level) Push(event Event, sublevels []string, columnRanges map[string][]ColumnRange)

Push pushes an event into the level.

func (*Level) RawEvents

func (l *Level) RawEvents() []Event

RawEvents returns the raw events represented by this level.

func (*Level) String

func (l *Level) String() string

func (*Level) Trim

func (l *Level) Trim()

Trim flattens a level and removes any unnecessary sublevels.

type LevelCursor

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

func (*LevelCursor) Err

func (cur *LevelCursor) Err() error

func (*LevelCursor) Next

func (cur *LevelCursor) Next() bool

func (*LevelCursor) Row

func (cur *LevelCursor) Row() query.Row

type Options

type Options struct {
	Fast     bool
	CostType int
}

Options represent different options to use during generation.

type StringColumnRange

type StringColumnRange struct {
	Min string `json:"min"`
	Max string `json:"max"`
}

StringColumnRange is a string column range.

func (StringColumnRange) Contains

func (r StringColumnRange) Contains(v interface{}) bool

Contains returns true if the range may contain v.

func (StringColumnRange) MinValue

func (r StringColumnRange) MinValue() interface{}

MinValue returns the min value in the range (inclusive).

func (StringColumnRange) Single

func (r StringColumnRange) Single() bool

Single returns true if the range represents a single value.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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