matrix

package
v0.0.0-...-68360ed Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package matrix abstracts the source data as Plane, and then pixelates it into a matrix for display on the front end.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPartOf

func CheckPartOf(src, part []string)

CheckPartOf checks that part keys are a subset of src keys.

func CheckReduceOf

func CheckReduceOf(src, part []string)

CheckReduceOf checks that part keys are a subset of src keys and have the same StartKey and EndKey.

func GetLastKey

func GetLastKey(keys []string) string

GetLastKey gets the last element of keys.

func KeysRange

func KeysRange(keys []string, startKey string, endKey string) (start, end int, ok bool)

KeysRange finds a range that intersects [startKey, endKey) in keys.

func MakeKeys

func MakeKeys(keySet map[string]struct{}) []string

MakeKeys uses a key set to build a new Key-Axis.

func MakeKeysWithUnlimitedEnd

func MakeKeysWithUnlimitedEnd(keySet map[string]struct{}) []string

MakeKeysWithUnlimitedEnd uses a key set to build a new Key-Axis, then add a "" to the keys, indicating that the last bucket has an unlimited end.

func Max

func Max(a, b int) int

Max returns the larger of a and b.

func MemsetInt

func MemsetInt(slice []int, v int)

MemsetInt sets all elements of the int slice to v.

func MemsetUint64

func MemsetUint64(slice []uint64, v uint64)

MemsetUint64 sets all elements of the uint64 slice to v.

func Min

func Min(a, b int) int

Min returns the smaller of a and b.

Types

type Axis

type Axis struct {
	Keys       []string
	ValuesList [][]uint64
}

Axis stores consecutive buckets. Each bucket has StartKey, EndKey, and some statistics. The EndKey of each bucket is the StartKey of its next bucket. The actual data structure is stored in columns. Therefore satisfies: len(Keys) == len(ValuesList[i]) + 1. In particular, ValuesList[0] is the base column.

func CreateAxis

func CreateAxis(keys []string, valuesList [][]uint64) Axis

CreateAxis checks the given parameters and uses them to build the Axis.

func CreateEmptyAxis

func CreateEmptyAxis(startKey, endKey string, valuesListLen int) Axis

CreateEmptyAxis constructs a minimal empty Axis with the given parameters.

func (*Axis) Divide

func (axis *Axis) Divide(labeler decorator.Labeler, target int) Axis

Divide uses the base column as the chunk for the Divide operation to obtain the partitioning scheme, and uses this to reduce other columns.

func (*Axis) Focus

func (axis *Axis) Focus(labeler decorator.Labeler, threshold uint64, ratio int, target int) Axis

Focus uses the base column as the chunk for the Focus operation to obtain the partitioning scheme, and uses this to reduce other columns.

func (*Axis) Range

func (axis *Axis) Range(startKey string, endKey string) Axis

Range returns a sub Axis with specified range.

func (*Axis) Shrink

func (axis *Axis) Shrink(ratio uint64)

Shrink reduces all statistical values.

type FocusMode

type FocusMode int
const (
	NotMergeLogicalRange FocusMode = iota
	MergeColdLogicalRange
)

type KeyMap

type KeyMap struct {
	sync.RWMutex
	sync.Map
}

KeyMap is used for string intern.

func (*KeyMap) SaveKey

func (km *KeyMap) SaveKey(key *string)

SaveKey interns a string.

func (*KeyMap) SaveKeys

func (km *KeyMap) SaveKeys(keys []string)

SaveKeys interns all strings without using mutex.

type Matrix

type Matrix struct {
	Keys     []string              `json:"-"`
	DataMap  map[string][][]uint64 `json:"data" binding:"required"`
	KeyAxis  []decorator.LabelKey  `json:"keyAxis" binding:"required"`
	TimeAxis []int64               `json:"timeAxis" binding:"required"`
}

Matrix is the front end displays the required data.

func CreateMatrix

func CreateMatrix(labeler decorator.Labeler, times []time.Time, keys []string, valuesListLen int) Matrix

CreateMatrix uses the specified times and keys to build an initial matrix with no data.

func (*Matrix) Range

func (mx *Matrix) Range(startKey, endKey string)

Range returns a sub Matrix with specified range.

type Plane

type Plane struct {
	Times []time.Time
	Axes  []Axis
}

Plane stores consecutive axes. Each axis has StartTime, EndTime. The EndTime of each axis is the StartTime of its next axis. Therefore satisfies: len(Times) == len(Axes) + 1.

func CreateEmptyPlane

func CreateEmptyPlane(startTime, endTime time.Time, startKey, endKey string, valuesListLen int) Plane

CreateEmptyPlane constructs a minimal empty Plane with the given parameters.

func CreatePlane

func CreatePlane(times []time.Time, axes []Axis) Plane

CreatePlane checks the given parameters and uses them to build the Plane.

func (*Plane) Compact

func (plane *Plane) Compact(strategy SplitStrategy) Axis

Compact compacts Plane into an axis.

func (*Plane) Pixel

func (plane *Plane) Pixel(strategy *Strategy, target int, displayTags []string) Matrix

Pixel pixelates Plane into a matrix with a number of rows close to the target.

type SplitStrategy

type SplitStrategy interface {
	NewSplitter(chunks []chunk, compactKeys []string) Splitter
}

SplitStrategy is an allocation scheme. It is used to generate a Splitter for a plane to split a chunk of columns.

func AverageSplitStrategy

func AverageSplitStrategy() SplitStrategy

AverageSplitStrategy adopts the strategy of equal distribution when buckets are split.

func DistanceSplitStrategy

func DistanceSplitStrategy(lc fx.Lifecycle, wg *sync.WaitGroup, ratio float64, level int, count int) SplitStrategy

type Splitter

type Splitter interface {
	// Split a chunk of columns.
	Split(dst, src chunk, tag splitTag, axesIndex int)
}

type Strategy

type Strategy struct {
	decorator.LabelStrategy
	SplitStrategy
}

Strategy is part of the customizable strategy in Matrix generation.

Jump to

Keyboard shortcuts

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