storage

package
v0.0.0-...-47e18b9 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package storage stores the input axes in order, and can get a Plane by time interval.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearTableAxisModel

func ClearTableAxisModel(db *dbstore.DB) error

func CreateStorageAxis

func CreateStorageAxis(regions region.RegionsInfo, strategy matrix.Strategy) matrix.Axis

CreateStorageAxis converts the RegionsInfo to a StorageAxis.

func CreateTableAxisModelIfNotExists

func CreateTableAxisModelIfNotExists(db *dbstore.DB) (bool, error)

If the table `AxisModel` exists, return true, nil or create table `AxisModel`

func DeleteAxisModelsByLayerNum

func DeleteAxisModelsByLayerNum(db *dbstore.DB, layerNum uint8) error

func IntoResponseAxis

func IntoResponseAxis(storageAxis matrix.Axis, baseTag region.StatTag) matrix.Axis

IntoResponseAxis converts StorageAxis to ResponseAxis.

func IntoStorageAxis

func IntoStorageAxis(responseAxis matrix.Axis, strategy matrix.Strategy) matrix.Axis

IntoStorageAxis converts ResponseAxis to StorageAxis.

Types

type AxisModel

type AxisModel struct {
	LayerNum uint8     `gorm:"unique_index:index_layer_time"`
	Time     time.Time `gorm:"unique_index:index_layer_time"`
	Axis     []byte
}

func FindAxisModelsOrderByTime

func FindAxisModelsOrderByTime(db *dbstore.DB, layerNum uint8) ([]*AxisModel, error)

func NewAxisModel

func NewAxisModel(layerNum uint8, time time.Time, axis matrix.Axis) (*AxisModel, error)

func (*AxisModel) Delete

func (a *AxisModel) Delete(db *dbstore.DB) error

func (*AxisModel) Insert

func (a *AxisModel) Insert(db *dbstore.DB) error

func (AxisModel) TableName

func (AxisModel) TableName() string

func (*AxisModel) UnmarshalAxis

func (a *AxisModel) UnmarshalAxis() (matrix.Axis, error)

type LayerConfig

type LayerConfig struct {
	Len   int
	Ratio int
}

LayerConfig is the configuration of layerStat.

type Stat

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

Stat is composed of multiple layerStats.

func NewStat

func NewStat(lc fx.Lifecycle, wg *sync.WaitGroup, db *dbstore.DB, cfg StatConfig, strategy matrix.Strategy, startTime time.Time) *Stat

NewStat generates a Stat based on the configuration.

func (*Stat) Append

func (s *Stat) Append(regions region.RegionsInfo, endTime time.Time)

Append adds the latest full statistics.

func (*Stat) Range

func (s *Stat) Range(startTime, endTime time.Time, startKey, endKey string, baseTag region.StatTag) matrix.Plane

Range returns a sub Plane with specified range.

func (*Stat) Restore

func (s *Stat) Restore() error

Restore data from db the first time service starts

type StatConfig

type StatConfig struct {
	LayersConfig []LayerConfig
}

StatConfig is the configuration of Stat.

Jump to

Keyboard shortcuts

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