join

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDebugEnabled added in v0.3.1

func IsDebugEnabled() bool

IsDebugEnabled returns whether debug logging is enabled.

func SetDebug added in v0.3.1

func SetDebug(enabled bool)

SetDebug enables or disables debug logging for the join package.

Types

type BushyJoinTreeBuilder

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

BushyJoinTreeBuilder Bushy Join Tree构建器 支持非线性(bushy)的JOIN树,提升多表JOIN性能

func NewBushyJoinTreeBuilder

func NewBushyJoinTreeBuilder(costModel *cost.AdaptiveCostModel, estimator interface{}, maxBushiness int) *BushyJoinTreeBuilder

NewBushyJoinTreeBuilder 创建Bushy JOIN Tree构建器

func (*BushyJoinTreeBuilder) BuildBushyTree

func (bjtb *BushyJoinTreeBuilder) BuildBushyTree(tables []string, joinNodes interface{}) interface{}

BuildBushyTree 构建Bushy JOIN Tree

func (*BushyJoinTreeBuilder) Explain

func (bjtb *BushyJoinTreeBuilder) Explain() string

Explain 解释Bushy Tree构建器

type CardinalityEstimator

type CardinalityEstimator interface {
	EstimateTableScan(tableName string) int64
}

CardinalityEstimator 基数估算器接口

type CostModel

type CostModel interface {
	ScanCost(tableName string, rowCount int64, useIndex bool) float64
	JoinCost(left, right LogicalPlan, joinType JoinType, conditions []*parser.Expression) float64
}

CostModel 成本模型接口

type DPJoinReorder

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

DPJoinReorder DP算法JOIN重排序器 使用动态规划算法寻找最优JOIN顺序

func NewDPJoinReorder

func NewDPJoinReorder(costModel CostModel, estimator CardinalityEstimator, maxTables int) *DPJoinReorder

NewDPJoinReorder 创建DP JOIN重排序器

func (*DPJoinReorder) Explain

func (dpr *DPJoinReorder) Explain(result *ReorderResult) string

Explain 解释重排序结果

func (*DPJoinReorder) Reorder

func (dpr *DPJoinReorder) Reorder(ctx context.Context, plan LogicalPlan) (LogicalPlan, error)

Reorder JOIN重排序(入口函数)

type DPState

type DPState struct {
	Order []string
	Cost  float64
	Left  string
	Right string
}

DPState DP状态

type GraphStats

type GraphStats struct {
	NodeCount   int
	EdgeCount   int
	MaxDegree   int
	MinDegree   int
	AvgDegree   float64
	IsConnected bool
	IsStar      bool
}

GraphStats 图统计信息

type JoinEdge

type JoinEdge struct {
	From        string  // 起始表
	To          string  // 目标表
	JoinType    string  // 连接类型
	Cardinality float64 // 估算的基数
}

JoinEdge JOIN图边

type JoinGraph

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

JoinGraph JOIN关系图 用于表示表之间的连接关系,辅助JOIN重排序

func NewJoinGraph

func NewJoinGraph() *JoinGraph

NewJoinGraph 创建JOIN图

func (*JoinGraph) AddEdge

func (jg *JoinGraph) AddEdge(from, to, joinType string, cardinality float64)

AddEdge 添加边(连接关系)

func (*JoinGraph) AddNode

func (jg *JoinGraph) AddNode(name string, cardinality int64)

AddNode 添加节点

func (*JoinGraph) EstimateJoinCardinality

func (jg *JoinGraph) EstimateJoinCardinality(from, to string) float64

EstimateJoinCardinality 估算JOIN的基数(基于图)

func (*JoinGraph) Explain

func (jg *JoinGraph) Explain() string

Explain 返回图的说明

func (*JoinGraph) FindMinSpanningTree

func (jg *JoinGraph) FindMinSpanningTree() []*JoinEdge

FindMinSpanningTree 查找最小生成树(Kruskal算法)

func (*JoinGraph) GetConnectedComponents

func (jg *JoinGraph) GetConnectedComponents() [][]string

GetConnectedComponents 获取连通分量

func (*JoinGraph) GetDegreeSequence

func (jg *JoinGraph) GetDegreeSequence() []int

GetDegreeSequence 获取度数序列(用于判断是否是星型图)

func (*JoinGraph) GetNeighbors

func (jg *JoinGraph) GetNeighbors(name string) []string

GetNeighbors 获取节点的邻居(有向图,只返回出边方向)

func (*JoinGraph) GetNode

func (jg *JoinGraph) GetNode(name string) *JoinNode

GetNode 获取节点

func (*JoinGraph) GetStats

func (jg *JoinGraph) GetStats() GraphStats

GetStats 获取图的统计信息

func (*JoinGraph) IsStarGraph

func (jg *JoinGraph) IsStarGraph() bool

IsStarGraph 判断是否是星型图(一个中心节点连接所有其他节点)

type JoinNode

type JoinNode struct {
	Name        string      // 表名
	Degree      int         // 度数(连接的边数)
	Edges       []*JoinEdge // 连接的边
	Cardinality int64       // 表基数(可选)
}

JoinNode JOIN图节点

type JoinType

type JoinType int

JoinType JOIN类型

const (
	InnerJoin JoinType = iota
	LeftOuterJoin
	RightOuterJoin
	FullOuterJoin
)

type LogicalPlan

type LogicalPlan interface {
	Children() []LogicalPlan
	Explain() string
}

LogicalPlan 逻辑计划接口(避免循环依赖)

type ReorderCache

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

ReorderCache 重排序缓存

func NewReorderCache

func NewReorderCache(size int) *ReorderCache

NewReorderCache 创建重排序缓存

func (*ReorderCache) Clear

func (rc *ReorderCache) Clear()

Clear 清空缓存

func (*ReorderCache) Get

func (rc *ReorderCache) Get(key string) *ReorderResult

Get 获取缓存的排序结果

func (*ReorderCache) Set

func (rc *ReorderCache) Set(key string, result *ReorderResult)

Set 设置缓存的排序结果

type ReorderResult

type ReorderResult struct {
	Order        []string
	Cost         float64
	JoinTreeType string // "left-deep", "right-deep", "bushy"
	Plan         LogicalPlan
}

ReorderResult 重排序结果

Jump to

Keyboard shortcuts

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