aggregates

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AggregateTable = map[string]execution.AggregatePrototype{
	"count":          func() execution.Aggregate { return NewCountAggregate() },
	"sum":            func() execution.Aggregate { return NewSumAggregate() },
	"avg":            func() execution.Aggregate { return NewAverageAggregate() },
	"min":            func() execution.Aggregate { return NewMinAggregate() },
	"max":            func() execution.Aggregate { return NewMaxAggregate() },
	"sum_distinct":   func() execution.Aggregate { return NewDistinctAggregate(NewSumAggregate()) },
	"count_distinct": func() execution.Aggregate { return NewDistinctAggregate(NewCountAggregate()) },
	"avg_distinct":   func() execution.Aggregate { return NewDistinctAggregate(NewAverageAggregate()) },
	"first":          func() execution.Aggregate { return NewFirstAggregate() },
	"last":           func() execution.Aggregate { return NewLastAggregate() },
	"key":            func() execution.Aggregate { return NewKeyAggregate() },
}

Functions

This section is empty.

Types

type Average

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

func NewAverageAggregate added in v0.3.0

func NewAverageAggregate() *Average

func (*Average) AddValue added in v0.3.0

func (agg *Average) AddValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Average) Document

func (agg *Average) Document() docs.Documentation

func (*Average) GetValue added in v0.3.0

func (agg *Average) GetValue(ctx context.Context, tx storage.StateTransaction) (octosql.Value, error)

func (*Average) RetractValue added in v0.3.0

func (agg *Average) RetractValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Average) String

func (agg *Average) String() string

type Count

type Count struct {
}

func NewCountAggregate added in v0.3.0

func NewCountAggregate() *Count

func (*Count) AddValue added in v0.3.0

func (agg *Count) AddValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Count) Document

func (agg *Count) Document() docs.Documentation

func (*Count) GetValue added in v0.3.0

func (agg *Count) GetValue(ctx context.Context, tx storage.StateTransaction) (octosql.Value, error)

func (*Count) RetractValue added in v0.3.0

func (agg *Count) RetractValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Count) String

func (agg *Count) String() string

type Distinct

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

func NewDistinctAggregate added in v0.3.0

func NewDistinctAggregate(aggr execution.Aggregate) *Distinct

func (*Distinct) AddValue added in v0.3.0

func (agg *Distinct) AddValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Distinct) Document

func (agg *Distinct) Document() docs.Documentation

func (*Distinct) GetValue added in v0.3.0

func (agg *Distinct) GetValue(ctx context.Context, tx storage.StateTransaction) (octosql.Value, error)

func (*Distinct) RetractValue added in v0.3.0

func (agg *Distinct) RetractValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Distinct) String

func (agg *Distinct) String() string

type First

type First struct {
}

func NewFirstAggregate added in v0.3.0

func NewFirstAggregate() *First

func (*First) AddValue added in v0.3.0

func (agg *First) AddValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

First storage contains Deque for actual order of elements added and Map for storing counts of every element. Once the element is added, we PushBack it into the Deque (because it is the last one to pick as 'first' in order). Above that, we increment its count in Map.

func (*First) Document

func (agg *First) Document() docs.Documentation

func (*First) GetValue added in v0.3.0

func (agg *First) GetValue(ctx context.Context, tx storage.StateTransaction) (octosql.Value, error)

Now the only think we need to do is PopFront ('front' because together with PushBack it creates a queue structure) first element which has positive count value (which means it wasn't fully retracted). If the front element doesn't have positive count, we need to 'forget' about its existence (as is described above RetractValue method), so we just Pop it.

func (*First) RetractValue added in v0.3.0

func (agg *First) RetractValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

Now, once the element is retracted we don't know its current position in Deque, so the only thing we can do is decrement its count value in Map (if it reaches 0, we will Pop it from deque during GetValue and don't bother)

func (*First) String

func (agg *First) String() string

type Key added in v0.3.0

type Key struct {
}

func NewKeyAggregate added in v0.3.0

func NewKeyAggregate() *Key

func (*Key) AddValue added in v0.3.0

func (agg *Key) AddValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Key) Document added in v0.3.0

func (agg *Key) Document() docs.Documentation

func (*Key) GetValue added in v0.3.0

func (agg *Key) GetValue(ctx context.Context, tx storage.StateTransaction) (octosql.Value, error)

func (*Key) RetractValue added in v0.3.0

func (agg *Key) RetractValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Key) String added in v0.3.0

func (agg *Key) String() string

type Last

type Last struct {
}

func NewLastAggregate added in v0.3.0

func NewLastAggregate() *Last

func (*Last) AddValue added in v0.3.0

func (agg *Last) AddValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

Last storage contains Deque for actual order of elements added and Map for storing counts of every element. Once the element is added, we PushFront it into the Deque (because it is the first one to pick as 'last' in order). Above that, we increment its count in Map.

func (*Last) Document

func (agg *Last) Document() docs.Documentation

func (*Last) GetValue added in v0.3.0

func (agg *Last) GetValue(ctx context.Context, tx storage.StateTransaction) (octosql.Value, error)

Now the only think we need to do is PopFront ('front' because together with PushFront it creates a stack structure) first element which has positive count value (which means it wasn't fully retracted). If the front element doesn't have positive count, we need to 'forget' about its existence (as is described above RetractValue method), so we just Pop it.

func (*Last) RetractValue added in v0.3.0

func (agg *Last) RetractValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

Now, once the element is retracted we don't know its current position in Deque, so the only thing we can do is decrement its count value in Map (if it reaches 0, we will Pop it from deque during GetValue and don't bother)

func (*Last) String

func (agg *Last) String() string

type Max

type Max struct {
}

func NewMaxAggregate added in v0.3.0

func NewMaxAggregate() *Max

func (*Max) AddValue added in v0.3.0

func (agg *Max) AddValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Max) Document

func (agg *Max) Document() docs.Documentation

func (*Max) GetValue added in v0.3.0

func (agg *Max) GetValue(ctx context.Context, tx storage.StateTransaction) (octosql.Value, error)

func (*Max) RetractValue added in v0.3.0

func (agg *Max) RetractValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Max) String

func (agg *Max) String() string

type Min

type Min struct {
}

func NewMinAggregate added in v0.3.0

func NewMinAggregate() *Min

func (*Min) AddValue added in v0.3.0

func (agg *Min) AddValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Min) Document

func (agg *Min) Document() docs.Documentation

func (*Min) GetValue added in v0.3.0

func (agg *Min) GetValue(ctx context.Context, tx storage.StateTransaction) (octosql.Value, error)

func (*Min) RetractValue added in v0.3.0

func (agg *Min) RetractValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Min) String

func (agg *Min) String() string

type Sum

type Sum struct {
}

func NewSumAggregate added in v0.3.0

func NewSumAggregate() *Sum

func (*Sum) AddValue added in v0.3.0

func (agg *Sum) AddValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Sum) Document

func (agg *Sum) Document() docs.Documentation

func (*Sum) GetValue added in v0.3.0

func (agg *Sum) GetValue(ctx context.Context, tx storage.StateTransaction) (octosql.Value, error)

func (*Sum) RetractValue added in v0.3.0

func (agg *Sum) RetractValue(ctx context.Context, tx storage.StateTransaction, value octosql.Value) error

func (*Sum) String

func (agg *Sum) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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