property

package
v1.1.0-beta.0...-0ffac36 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoCTEOrAllProducerCanMPP cteProducerStatus = iota
	SomeCTEFailedMpp
	AllCTECanMpp
)

Constants for CTE status.

Variables

This section is empty.

Functions

func ExplainColumnList

func ExplainColumnList(ctx expression.EvalContext, cols []*MPPPartitionColumn) []byte

ExplainColumnList generates explain information for a list of columns.

func GetCollateIDByNameForPartition

func GetCollateIDByNameForPartition(coll string) int32

GetCollateIDByNameForPartition returns collate id by collation name

func GetCollateNameByIDForPartition

func GetCollateNameByIDForPartition(collateID int32) string

GetCollateNameByIDForPartition returns collate id by collation name

func ToString

func ToString(ndvs []GroupNDV) string

ToString prints GroupNDV slice. It is only used for test.

Types

type GroupNDV

type GroupNDV struct {
	// Cols are the UniqueIDs of columns.
	Cols []int64
	NDV  float64
}

GroupNDV stores the NDV of a group of columns.

type LogicalProperty

type LogicalProperty struct {
	Stats     *StatsInfo
	Schema    *expression.Schema
	MaxOneRow bool
}

LogicalProperty stands for logical properties such as schema of expression, or statistics of columns in schema for output of Group. All group expressions in a group share same logical property.

type MPPPartitionColumn

type MPPPartitionColumn struct {
	Col       *expression.Column
	CollateID int32
}

MPPPartitionColumn is the column that will be used in MPP Hash Exchange

func (*MPPPartitionColumn) Clone

func (partitionCol *MPPPartitionColumn) Clone() *MPPPartitionColumn

Clone makes a copy of MPPPartitionColumn.

func (*MPPPartitionColumn) Equal

func (partitionCol *MPPPartitionColumn) Equal(other *MPPPartitionColumn) bool

Equal returns true if partitionCol == other

func (*MPPPartitionColumn) MemoryUsage

func (partitionCol *MPPPartitionColumn) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of MPPPartitionColumn

type MPPPartitionType

type MPPPartitionType int

MPPPartitionType is the way to partition during mpp data exchanging.

const (
	// AnyType will not require any special partition types.
	AnyType MPPPartitionType = iota
	// BroadcastType requires current task to broadcast its data.
	BroadcastType
	// HashType requires current task to shuffle its data according to some columns.
	HashType
	// SinglePartitionType requires all the task pass the data to one node (tidb/tiflash).
	SinglePartitionType
)

func (MPPPartitionType) ToExchangeType

func (t MPPPartitionType) ToExchangeType() tipb.ExchangeType

ToExchangeType generates ExchangeType from MPPPartitionType

type PhysicalProperty

type PhysicalProperty struct {
	// SortItems contains the required sort attributes.
	SortItems []SortItem

	// TaskTp means the type of task that an operator requires.
	//
	// It needs to be specified because two different tasks can't be compared
	// with cost directly. e.g. If a copTask takes less cost than a rootTask,
	// we can't sure that we must choose the former one. Because the copTask
	// must be finished and increase its cost in sometime, but we can't make
	// sure the finishing time. So the best way to let the comparison fair is
	// to add TaskType to required property.
	TaskTp TaskType

	// ExpectedCnt means this operator may be closed after fetching ExpectedCnt
	// records.
	ExpectedCnt float64

	// indicates that whether we are allowed to add an enforcer.
	CanAddEnforcer bool

	// If the partition type is hash, the data should be reshuffled by partition cols.
	MPPPartitionCols []*MPPPartitionColumn

	// which types the exchange sender belongs to, only take effects when it's a mpp task.
	MPPPartitionTp MPPPartitionType

	// SortItemsForPartition means these sort only need to sort the data of one partition, instead of global.
	// It is added only if it is used to sort the sharded data of the window function.
	// Non-MPP tasks do not care about it.
	SortItemsForPartition []SortItem

	// RejectSort means rejecting the sort property from its children, but it only works for MPP tasks.
	// Non-MPP tasks do not care about it.
	RejectSort bool

	CTEProducerStatus cteProducerStatus

	VectorProp struct {
		*expression.VectorHelper
		TopK uint32
	}
	// contains filtered or unexported fields
}

PhysicalProperty stands for the required physical property by parents. It contains the orders and the task types.

func NewPhysicalProperty

func NewPhysicalProperty(taskTp TaskType, cols []*expression.Column,
	desc bool, expectCnt float64, enforced bool) *PhysicalProperty

NewPhysicalProperty builds property from columns.

func (*PhysicalProperty) AllColsFromSchema

func (p *PhysicalProperty) AllColsFromSchema(schema *expression.Schema) bool

AllColsFromSchema checks whether all the columns needed by this physical property can be found in the given schema.

func (*PhysicalProperty) AllSameOrder

func (p *PhysicalProperty) AllSameOrder() (isSame bool, desc bool)

AllSameOrder checks if all the items have same order.

func (*PhysicalProperty) CloneEssentialFields

func (p *PhysicalProperty) CloneEssentialFields() *PhysicalProperty

CloneEssentialFields returns a copy of PhysicalProperty. We only copy the essential fields that really indicate the property, specifically, `CanAddEnforcer` should not be included.

func (*PhysicalProperty) GetAllPossibleChildTaskTypes

func (p *PhysicalProperty) GetAllPossibleChildTaskTypes() []TaskType

GetAllPossibleChildTaskTypes enumrates the possible types of tasks for children.

func (*PhysicalProperty) HashCode

func (p *PhysicalProperty) HashCode() []byte

HashCode calculates hash code for a PhysicalProperty object.

func (*PhysicalProperty) IsFlashProp

func (p *PhysicalProperty) IsFlashProp() bool

IsFlashProp return true if this physical property is only allowed to generate flash related task

func (*PhysicalProperty) IsPrefix

func (p *PhysicalProperty) IsPrefix(prop *PhysicalProperty) bool

IsPrefix checks whether the order property is the prefix of another.

func (*PhysicalProperty) IsSortItemAllForPartition

func (p *PhysicalProperty) IsSortItemAllForPartition() bool

IsSortItemAllForPartition check whether SortItems is same as SortItemsForPartition

func (*PhysicalProperty) IsSortItemEmpty

func (p *PhysicalProperty) IsSortItemEmpty() bool

IsSortItemEmpty checks whether the order property is empty.

func (*PhysicalProperty) IsSubsetOf

func (p *PhysicalProperty) IsSubsetOf(keys []*MPPPartitionColumn) []int

IsSubsetOf check if the keys can match the needs of partition.

func (*PhysicalProperty) MemoryUsage

func (p *PhysicalProperty) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of PhysicalProperty

func (*PhysicalProperty) String

func (p *PhysicalProperty) String() string

String implements fmt.Stringer interface. Just for test.

type SortItem

type SortItem struct {
	Col  *expression.Column
	Desc bool
}

SortItem wraps the column and its order.

func SortItemsFromCols

func SortItemsFromCols(cols []*expression.Column, desc bool) []SortItem

SortItemsFromCols builds property items from columns.

func (SortItem) Clone

func (s SortItem) Clone() SortItem

Clone makes a copy of SortItem.

func (*SortItem) Equals

func (s *SortItem) Equals(other any) bool

Equals implements the HashEquals interface.

func (*SortItem) Hash64

func (s *SortItem) Hash64(h base.Hasher)

Hash64 implements the HashEquals interface.

func (SortItem) MemoryUsage

func (s SortItem) MemoryUsage() (sum int64)

MemoryUsage return the memory usage of SortItem

func (*SortItem) String

func (s *SortItem) String() string

type StatsInfo

type StatsInfo struct {
	RowCount float64

	// Column.UniqueID -> NDV
	ColNDVs map[int64]float64

	HistColl *statistics.HistColl
	// StatsVersion indicates the statistics version of a table.
	// If the StatsInfo is calculated using the pseudo statistics on a table, StatsVersion will be PseudoVersion.
	StatsVersion uint64

	// GroupNDVs stores the NDV of column groups.
	GroupNDVs []GroupNDV
}

StatsInfo stores the basic information of statistics for the plan's output. It is used for cost estimation.

func (*StatsInfo) Count

func (s *StatsInfo) Count() int64

Count gets the RowCount in the StatsInfo.

func (*StatsInfo) GetGroupNDV4Cols

func (s *StatsInfo) GetGroupNDV4Cols(cols []*expression.Column) *GroupNDV

GetGroupNDV4Cols gets the GroupNDV for the given columns.

func (*StatsInfo) Scale

func (s *StatsInfo) Scale(factor float64) *StatsInfo

Scale receives a selectivity and multiplies it with RowCount and NDV.

func (*StatsInfo) ScaleByExpectCnt

func (s *StatsInfo) ScaleByExpectCnt(expectCnt float64) *StatsInfo

ScaleByExpectCnt tries to Scale StatsInfo to an expectCnt which must be smaller than the derived cnt. TODO: try to use a better way to do this.

func (*StatsInfo) String

func (s *StatsInfo) String() string

String implements fmt.Stringer interface.

type TaskType

type TaskType int

TaskType is the type of execution task.

const (
	// RootTaskType stands for the tasks that executed in the TiDB layer.
	RootTaskType TaskType = iota

	// CopSingleReadTaskType stands for the a TableScan or IndexScan tasks
	// executed in the coprocessor layer.
	CopSingleReadTaskType

	// CopMultiReadTaskType stands for the a IndexLookup tasks executed in the
	// coprocessor layer.
	CopMultiReadTaskType

	// MppTaskType stands for task that would run on Mpp nodes, currently meaning the tiflash node.
	MppTaskType
)

func (TaskType) String

func (t TaskType) String() string

String implements fmt.Stringer interface.

Jump to

Keyboard shortcuts

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