metadata

package
v0.0.0-...-4b2efa1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColumnNameTS  = "ts"
	ColumnNameVIN = "vin"
	ColumnNameExt = "ext"
)
View Source
const (
	TSColumnIndex  = 0 // ts column is supposed to be the first column
	VINColumnIndex = 1 // vin column is supposed to be the second column
)
View Source
const (
	ColumnSizeVin         int64 = 32 // TODO: average vin size
	ColumnSizeTimestamp   int64 = 8
	ColumnSizeTimestampTZ int64 = 8
)
View Source
const (
	// TODO: make it configurable
	MAX_SIMPLE_COLUMN_NUM  = 1000
	NON_METRICS_COLUMN_NUM = 2 // ts, vin
	EXT_COLUMN_NUM         = 1 // only 1 ext column, json/jsonb
)
View Source
const (
	OutOrderDuration = 24 * time.Hour
)

Variables

This section is empty.

Functions

func NewColumn

func NewColumn(n ColumnName, t ColumnType) *mxmock.Column

func NewColumnsFromColumnsDescriptions

func NewColumnsFromColumnsDescriptions(columnDescs MetricsDescriptions) (Columns, ColumnSpecs)

NewColumnsFromColumnsDescriptions creates a slice of columns accord to columnDescs

func Size

func Size(t MetricsType) int64

Types

type ColumnName

type ColumnName = string

type ColumnSpec

type ColumnSpec struct {
	IsExt               bool                `json:"is-ext"`
	ColumnsDescriptions MetricsDescriptions `json:"columns-descriptions"`

	Name          string  `json:"name"`
	Min           float64 `json:"min"`
	Max           float64 `json:"max"`
	IsRounded     bool    `json:"is-rounded"`
	DecimalPlaces uint    `json:"decimal-places"`
}

func NewExtColumnFromColumnsDescriptions

func NewExtColumnFromColumnsDescriptions(n ColumnName, t ColumnType, columnsDescs MetricsDescriptions) (*mxmock.Column, *ColumnSpec, error)

NewExtColumnFromColumnsDescriptions creates a column with the name n and type t. For it will be used as the ext column, a specification to indicate its usage and included metrics is to be properly set.

type ColumnSpecs

type ColumnSpecs []*ColumnSpec

type ColumnType

type ColumnType = string
const (
	ColumnTypeTimestamp   ColumnType = "timestamp"
	ColumnTypeTimestampTZ ColumnType = "timestamptz"

	ColumnTypeText    ColumnType = "text"
	ColumnTypeVarChar ColumnType = "varchar"

	ColumnTypeInt4 = "int4"
	ColumnTypeInt8 = "int8"

	ColumnTypeJSON  ColumnType = "json"
	ColumnTypeJSONB ColumnType = "jsonb"
)

type Columns

type Columns []*mxmock.Column

func (Columns) ToSQLStr

func (cs Columns) ToSQLStr() string

Parse columns to:

	ts  timestamp
  , vin text
  , c0  float4
  , ...
  , cn float4

func (Columns) ToSelectSQLStr

func (cs Columns) ToSelectSQLStr(tableAlias string) string

type Config

type Config struct {
	SchemaName              string
	TableName               string
	TagNum                  int64
	StartAt                 time.Time
	EndAt                   time.Time
	PartitionIntervalInHour int64
	MetricsType             MetricsType
	StorageType             StorageType
	TotalMetricsCount       int64
	MetricsDescriptions     string
	TimestampStepInSecond   uint64
	HasUniqueConstraints    bool
	EmptyValueRatio         int
	IsDDLFromFile           bool
	DB                      util.DBConnParams
	DBVersion               util.DBVersion
}

type DurationGenerator

type DurationGenerator func() (string, string)

type GUC

type GUC struct {
	Name            string
	ValueOnMaster   string
	ValueOnSegments string
}

func NewGUC

func NewGUC(name, masterValue, segmentValue string) *GUC

func NewGUCForBothRoles

func NewGUCForBothRoles(name, value string) *GUC

func (*GUC) String

func (g *GUC) String() string

type GUCs

type GUCs []*GUC

func NewGUCs

func NewGUCs(cfg *Config) GUCs

func (GUCs) SetGUCsCommand

func (gs GUCs) SetGUCsCommand() string

func (GUCs) String

func (gs GUCs) String() string

type Index

type Index interface {
	GetCreateIndexSQLStr() string
}

func NewMars2BTree

func NewMars2BTree(table *Table, timeBucketInSecond int, hasUniqueConstraints bool) Index

func NewMars3BTree

func NewMars3BTree(table *Table) Index

type IndexType

type IndexType = string
const (
	IndexMars2BTree IndexType = "mars2_btree"
	IndexMars3BTree IndexType = "mars3_brin"
)

type Indexes

type Indexes []Index

type Mars2BTree

type Mars2BTree struct {
	Table      *Table
	UniqueMode bool

	// TODO: time_bucket related settings are deprecated in mars2_btree
	TimeBucketInSecond int
	TimestampColumn    ColumnName

	TagColumn ColumnName
	// contains filtered or unexported fields
}

func (*Mars2BTree) GetCreateIndexSQLStr

func (s *Mars2BTree) GetCreateIndexSQLStr() string

func (*Mars2BTree) Identifier

func (s *Mars2BTree) Identifier() string

type Mars3BTree

type Mars3BTree struct {
	Table           *Table
	TimestampColumn ColumnName
	TagColumn       ColumnName
	// contains filtered or unexported fields
}

func (*Mars3BTree) GetCreateIndexSQLStr

func (s *Mars3BTree) GetCreateIndexSQLStr() string

func (*Mars3BTree) Identifier

func (s *Mars3BTree) Identifier() string

type Metadata

type Metadata struct {
	GUCs  GUCs
	Table *Table
	Cfg   *Config
}

func New

func New(cfg *Config) (*Metadata, error)

func (*Metadata) GetDDL

func (meta *Metadata) GetDDL() string

func (*Metadata) GetFixedStartEndTSArgGenerator

func (meta *Metadata) GetFixedStartEndTSArgGenerator(startTime, endTime string) DurationGenerator

func (*Metadata) GetGUCs

func (meta *Metadata) GetGUCs() string

func (*Metadata) GetRandomStartEndTSArgGenerator

func (meta *Metadata) GetRandomStartEndTSArgGenerator(duration time.Duration) DurationGenerator

func (*Metadata) GetRandomVinsGenerator

func (meta *Metadata) GetRandomVinsGenerator(num int) func() string

func (*Metadata) GetSingleVinGenerator

func (meta *Metadata) GetSingleVinGenerator() SingleVinGenerator

func (*Metadata) GetTableSizeSQL

func (meta *Metadata) GetTableSizeSQL() string

func (*Metadata) ToJSONColStr

func (meta *Metadata) ToJSONColStr(jsonColumnsDescs MetricsDescriptions, jsonMetricsNum int64) string

func (*Metadata) ToJSONSelectStr

func (meta *Metadata) ToJSONSelectStr(jsonColumnsDescs MetricsDescriptions, tableAlias string, jsonMetricsNum int64) string

type MetricsDescription

type MetricsDescription struct {
	MetricsType MetricsType `json:"type"`
	Count       int64       `json:"count"`
	Spec        ColumnSpec  `json:"comment"`
}

type MetricsDescriptions

type MetricsDescriptions []*MetricsDescription

type MetricsType

type MetricsType = ColumnType
const (
	MetricsTypeFloat4 MetricsType = "float4"
	MetricsTypeFloat8 MetricsType = "float8"
	MetricsTypeInt4   MetricsType = "int4"
	MetricsTypeInt8   MetricsType = "int8"
	MetricsTypeJSON   MetricsType = "json"
	MetricsTypeJSONB  MetricsType = "jsonb"
)

type MultiVinsGenerator

type MultiVinsGenerator func() string

type Option

type Option struct {
	Name  string
	Value interface{}
}

type Options

type Options []*Option

func (Options) ToSQLStr

func (opts Options) ToSQLStr() string

type SingleVinGenerator

type SingleVinGenerator func() string

type StorageType

type StorageType = string
const (
	StorageMars2 StorageType = "mars2"
	StorageMars3 StorageType = "mars3"
	StorageHeap  StorageType = "heap"
)

type Table

type Table struct {
	Columns                  Columns
	ColumnSpecs              ColumnSpecs
	TotalMetricsCount        int64
	JSONMetricsCount         int64
	JSONMetricsCandidateType MetricsType

	ColumnNameTS, ColumnNameVIN, ColumnNameExt string
	ColumnTypeTS, ColumnTypeVIN, ColumnTypeExt ColumnType

	ExtColumn       *mxmock.Column
	ColumnsDescsExt MetricsDescriptions
	VinValues       []string

	// if it is from DDL, then the fields below are disabled
	// TODO: may also do initialization in the future
	DistKey    string
	OrderByKey []string
	Storage    StorageType
	Options    Options
	Indexes    Indexes
	// contains filtered or unexported fields
}

func NewHeapTable

func NewHeapTable(cfg *Config) (*Table, error)

func NewMarsTable

func NewMarsTable(cfg *Config, st StorageType) (*Table, error)

NewMarsTable creates a mars2 or mars3 table with an index according to config.

func NewTable

func NewTable(cfg *Config, st StorageType) (*Table, error)

func NewTableFromColumns

func NewTableFromColumns(schemaName, tableName string, columns Columns) (*Table, error)

func NewTableFromDB

func NewTableFromDB(cfg *Config) (*Table, error)

func (*Table) Identifier

func (t *Table) Identifier() string

func (*Table) SingleRowMetricsSize

func (t *Table) SingleRowMetricsSize() int64

Jump to

Keyboard shortcuts

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