statistics

package
v1.5.3-rc5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSelectivity = 0.0

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnStatistics

type ColumnStatistics struct {
	ColumnName  string
	RowCount    uint64
	NullCount   uint64
	Cardinality uint64
	LastUpdated int64
	MinVal      interface{}
	MaxVal      interface{}
	Histogram   Histogram // Histogram
}

ColumnStatistics represents column-level statistical information.

type Histogram

type Histogram interface {
	// EstimateSelectivity estimates the selectivity of a given expression.
	EstimateSelectivity(expr influxql.Expr) float64

	// Update updates the histogram with a set of values.
	Update(values ...interface{})

	// Serialize serializes the histogram into a byte slice.
	Serialize() ([]byte, error)

	// Deserialize deserializes the histogram from a byte slice.
	Deserialize(data []byte) error
}

Histogram is the interface for a histogram.

type JoinStatistics

type JoinStatistics struct {
	LeftRows      uint64
	RightRows     uint64
	EstimatedRows uint64  // Estimated number of join result rows
	Selectivity   float64 // Selectivity
}

JoinStatistics represents join operation statistical information.

type NumericBin

type NumericBin struct {
	Min     float64
	Max     float64
	Count   uint64
	Density float64
}

NumericBin represents a bin in a numeric histogram.

type NumericHistogram

type NumericHistogram struct {
	Bins       []NumericBin // sorted by Min Max value
	TotalCount uint64
	Name       string
}

NumericHistogram represents a numeric histogram. All data should fall between the minimum value of the first bucket and the maximum value of the last bucket.

func (*NumericHistogram) Deserialize

func (h *NumericHistogram) Deserialize(data []byte) error

Deserialize deserializes the histogram from a byte slice.

func (*NumericHistogram) EstimateSelectivity

func (h *NumericHistogram) EstimateSelectivity(expr influxql.Expr) float64

EstimateSelectivity estimates the selectivity of a given expression using binary search and cumulative density.

func (*NumericHistogram) Serialize

func (h *NumericHistogram) Serialize() ([]byte, error)

Serialize serializes the histogram into a byte slice.

func (*NumericHistogram) Update

func (h *NumericHistogram) Update(values ...interface{})

Update updates the histogram with a set of values.

type StatisticsManager

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

StatisticsManager is the manager for statistical information.

func NewStatisticsManager

func NewStatisticsManager(store engine.Engine) *StatisticsManager

NewStatisticsManager creates a new StatisticsManager instance.

func (*StatisticsManager) GetColumnStats

func (m *StatisticsManager) GetColumnStats(measurement, column string) (*ColumnStatistics, error)

GetColumnStats retrieves column statistics for a specified measurement and column.

func (*StatisticsManager) GetJoinStats

func (m *StatisticsManager) GetJoinStats(left, right string, condition influxql.Expr) (*JoinStatistics, error)

GetJoinStats retrieves join operation statistics for specified left and right measurements with a condition.

func (*StatisticsManager) GetTableStats

func (m *StatisticsManager) GetTableStats(measurement string) (*TableStatistics, error)

GetTableStats retrieves table statistics for a given measurement.

func (*StatisticsManager) GetTagStats

func (m *StatisticsManager) GetTagStats(measurement, tag string) (*TagStatistics, error)

GetTagStats retrieves tag statistics for a specified measurement and tag.

func (*StatisticsManager) LoadFromStorage

func (m *StatisticsManager) LoadFromStorage() error

LoadFromStorage loads all statistical information from storage.

func (*StatisticsManager) SaveToStorage

func (m *StatisticsManager) SaveToStorage() error

SaveToStorage persists all statistical information to storage.

func (*StatisticsManager) UpdateColumnStats

func (m *StatisticsManager) UpdateColumnStats(measurement, column string, stats *ColumnStatistics) error

UpdateColumnStats updates column statistics for a specified measurement and column.

func (*StatisticsManager) UpdateTableStats

func (m *StatisticsManager) UpdateTableStats(measurement string, stats *TableStatistics) error

UpdateTableStats updates table statistics for a given measurement.

func (*StatisticsManager) UpdateTagStats

func (m *StatisticsManager) UpdateTagStats(measurement, tag string, stats *TagStatistics) error

UpdateTagStats updates tag statistics for a specified measurement and tag.

type StatisticsProvider

type StatisticsProvider interface {
	// GetTableStats retrieves table-level statistics for a given measurement.
	GetTableStats(measurement string) (*TableStatistics, error)

	// GetColumnStats retrieves column-level statistics for a specified measurement and column.
	GetColumnStats(measurement, column string) (*ColumnStatistics, error)

	// GetTagStats retrieves tag-level statistics for a specified measurement and tag.
	GetTagStats(measurement, tag string) (*TagStatistics, error)

	// GetJoinStats retrieves join operation statistics for specified left and right measurements with a condition.
	GetJoinStats(left, right string, condition influxql.Expr) (*JoinStatistics, error)

	// UpdateTableStats updates the table-level statistics for a given measurement.
	UpdateTableStats(measurement string, stats *TableStatistics) error

	// UpdateColumnStats updates the column-level statistics for a specified measurement and column.
	UpdateColumnStats(measurement, column string, stats *ColumnStatistics) error

	// UpdateTagStats updates the tag-level statistics for a specified measurement and tag.
	UpdateTagStats(measurement, tag string, stats *TagStatistics) error

	// SaveToStorage persists the statistical information to storage.
	SaveToStorage() error

	// LoadFromStorage loads the statistical information from storage.
	LoadFromStorage() error
}

StatisticsProvider is the interface for providing statistical information.

type TableStatistics

type TableStatistics struct {
	Measurement   string
	RowCount      uint64
	LastUpdated   int64
	TagCount      int             // Number of tags
	FieldCount    int             // Number of fields
	SeriesCount   uint64          // Number of series
	AvgSeriesSize float64         // Average series size
	TimeRange     *TimeRangeStats // Time range statistics
}

TableStatistics represents table-level statistical information.

type TagStatistics

type TagStatistics struct {
	TagName     string
	Cardinality uint64 // Cardinality
	LastUpdated int64
	TopValues   []TagValueFreq // Top values
}

TagStatistics represents tag-level statistical information.

type TagValueFreq

type TagValueFreq struct {
	Value interface{}
	Freq  float64 // Frequency proportion
	Count uint64  // Count
}

TagValueFreq represents the frequency of a tag value.

type TimeRangeStats

type TimeRangeStats struct {
	MinTime     int64
	MaxTime     int64
	TimeSpan    time.Duration // Time span
	AvgInterval float64       // Average time interval (in seconds)
}

TimeRangeStats represents time range statistical information.

Jump to

Keyboard shortcuts

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