usage

package
v1.1.0-beta.0...-83d3794 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DumpStatsDeltaRatio is the lower bound of `Modify Count / Table Count` for stats delta to be dumped.
	DumpStatsDeltaRatio = 1 / 10000.0
)

Functions

func DumpColStatsUsageEntries

func DumpColStatsUsageEntries(pool syssession.Pool, entries []ColStatsUsageEntry, rec TimeCostRecorderForTest) error

DumpColStatsUsageEntries batches and executes the insert/update for column_stats_usage.

func NewStatsUsageImpl

func NewStatsUsageImpl(statsHandle statstypes.StatsHandle) statstypes.StatsUsage

NewStatsUsageImpl creates a statstypes.StatsUsage.

Types

type ColStatsUsageEntry

type ColStatsUsageEntry struct {
	LastUsedAt string
	TableID    int64
	ColumnID   int64
}

ColStatsUsageEntry represents one (table_id, column_id, last_used_at) item to persist.

type SessionStatsItem

type SessionStatsItem struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SessionStatsItem is a list item that holds the delta mapper. If you want to write or read mapper, you must lock it.

func (*SessionStatsItem) ClearForTest

func (s *SessionStatsItem) ClearForTest()

ClearForTest clears the mapper for test.

func (*SessionStatsItem) Delete

func (s *SessionStatsItem) Delete()

Delete only sets the deleted flag true, it will be deleted from list when DumpStatsDeltaToKV is called.

func (*SessionStatsItem) Update

func (s *SessionStatsItem) Update(id int64, delta int64, count int64)

Update will updates the delta and count for one table id.

func (*SessionStatsItem) UpdateColStatsUsage

func (s *SessionStatsItem) UpdateColStatsUsage(colItems iter.Seq[model.TableItemID], updateTime time.Time)

UpdateColStatsUsage updates the last time when the column stats are used(needed).

type SessionStatsList

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

SessionStatsList is a list of SessionStatsItem, which is used to collect stats usage and table delta information from sessions. TODO: merge SessionIndexUsage into this list.

[session1]                [session2]                        [sessionN]
    |                         |                                 |
update into              update into                       update into
    |                         |                                 |
    v                         v                                 v

[StatsList.Head] --> [session1.StatsItem] --> [session2.StatsItem] --> ... --> [sessionN.StatsItem]

|                         |                                 |
+-------------------------+---------------------------------+
                          |
        collect and dump into storage periodically
                          |
                          v
                      [storage]

func NewSessionStatsList

func NewSessionStatsList() *SessionStatsList

NewSessionStatsList initializes a new SessionStatsList.

func (*SessionStatsList) NewSessionStatsItem

func (sl *SessionStatsList) NewSessionStatsItem() *SessionStatsItem

NewSessionStatsItem allocates a stats collector for a session.

func (*SessionStatsList) ResetSessionStatsList

func (sl *SessionStatsList) ResetSessionStatsList()

ResetSessionStatsList resets this list.

func (*SessionStatsList) SessionStatsUsage

func (sl *SessionStatsList) SessionStatsUsage() *StatsUsage

SessionStatsUsage returns the current *StatsUsage.

func (*SessionStatsList) SessionTableDelta

func (sl *SessionStatsList) SessionTableDelta() *TableDeltaMap

SessionTableDelta returns the current *TableDeltaMap.

func (*SessionStatsList) SweepSessionStatsList

func (sl *SessionStatsList) SweepSessionStatsList()

SweepSessionStatsList will loop over the list, merge each session's local stats into handle and remove closed session's collector.

type StatsUsage

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

StatsUsage maps (tableID, columnID) to the last time when the column stats are used(needed). All methods of it are thread-safe.

func NewStatsUsage

func NewStatsUsage() *StatsUsage

NewStatsUsage creates a new StatsUsage.

func (*StatsUsage) GetUsageAndReset

func (m *StatsUsage) GetUsageAndReset() map[model.TableItemID]time.Time

GetUsageAndReset gets the usage and resets the StatsUsage.

func (*StatsUsage) Merge

func (m *StatsUsage) Merge(other map[model.TableItemID]time.Time)

Merge merges the usageMap into the StatsUsage.

func (*StatsUsage) MergeRawData

func (m *StatsUsage) MergeRawData(raw iter.Seq[model.TableItemID], updateTime time.Time)

MergeRawData merges the new data passed by iterator.

func (*StatsUsage) Reset

func (m *StatsUsage) Reset()

Reset resets the StatsUsage.

type TableDeltaMap

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

TableDeltaMap is used to collect tables' change information. All methods of it are thread-safe.

func NewTableDeltaMap

func NewTableDeltaMap() *TableDeltaMap

NewTableDeltaMap creates a new TableDeltaMap.

func (*TableDeltaMap) GetDeltaAndReset

func (m *TableDeltaMap) GetDeltaAndReset() map[int64]variable.TableDelta

GetDeltaAndReset gets the delta and resets the TableDeltaMap.

func (*TableDeltaMap) Merge

func (m *TableDeltaMap) Merge(deltaMap map[int64]variable.TableDelta)

Merge merges the deltaMap into the TableDeltaMap.

func (*TableDeltaMap) Reset

func (m *TableDeltaMap) Reset()

Reset resets the TableDeltaMap.

func (*TableDeltaMap) Update

func (m *TableDeltaMap) Update(id int64, delta int64, count int64)

Update updates the delta of the table.

type TimeCostRecorderForTest

type TimeCostRecorderForTest interface {
	Record(duration time.Duration)
}

TimeCostRecorderForTest can collect per-batch timings when provided in tests.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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