Documentation
¶
Overview ¶
Package plan implements the Ivfpq plugin's plan-layer hooks. Phase 6 split: bodies live in pkg/sql/plan; this file is thin redirects. See pkg/vectorindex/hnsw/plugin/plan/plan.go for the canonical template.
Index ¶
- Constants
- Variables
- type Hooks
- func (Hooks) ApplyForSort(pb planplugin.PlanBuilder, vctx *planplugin.VectorSortContext, ...) (int32, bool, error)
- func (Hooks) BuildFullTextIndexDefs(_ planplugin.CompilerContext, _ *tree.FullTextIndex, _ map[string]*plan.ColDef, ...) ([]*plan.IndexDef, []*plan.TableDef, error)
- func (Hooks) BuildSecondaryIndexDefs(ctx planplugin.CompilerContext, indexInfo *tree.Index, ...) ([]*plan.IndexDef, []*plan.TableDef, error)
- func (Hooks) CanApply(pb planplugin.PlanBuilder, vctx *planplugin.VectorSortContext, ...) (bool, error)
Constants ¶
const ( IVFPQCreateFuncName = "ivfpq_create" IVFPQSearchFuncName = "ivfpq_search" )
Variables ¶
var ( // IVFPQSearchColDefs is the (pkid, score) schema the ivfpq_search // table function returns. Exported so the ApplyForSort body in // plan.go can reference it. IVFPQSearchColDefs = []*plan.ColDef{ { Name: "pkid", Typ: plan.Type{ Id: int32(types.T_int64), NotNullable: false, Width: 8, }, }, { Name: "score", Typ: plan.Type{ Id: int32(types.T_float64), NotNullable: false, Width: 8, }, }, } )
Functions ¶
This section is empty.
Types ¶
type Hooks ¶
type Hooks struct{}
func (Hooks) ApplyForSort ¶
func (Hooks) ApplyForSort(pb planplugin.PlanBuilder, vctx *planplugin.VectorSortContext, mti *planplugin.MultiTableIndexRef, nodeID int32, opts planplugin.ApplyForSortOpts) (int32, bool, error)
func (Hooks) BuildFullTextIndexDefs ¶
func (Hooks) BuildFullTextIndexDefs( _ planplugin.CompilerContext, _ *tree.FullTextIndex, _ map[string]*plan.ColDef, _ []*plan.IndexDef, _ string, ) ([]*plan.IndexDef, []*plan.TableDef, error)
BuildFullTextIndexDefs is unreachable for ivfpq — the plan-build dispatch only routes *tree.FullTextIndex parse trees to the fulltext plugin. Returning an error here makes any misrouting visible.
func (Hooks) BuildSecondaryIndexDefs ¶
func (Hooks) BuildSecondaryIndexDefs( ctx planplugin.CompilerContext, indexInfo *tree.Index, colMap map[string]*plan.ColDef, existedIndexes []*plan.IndexDef, pkeyName string, ) ([]*plan.IndexDef, []*plan.TableDef, error)
BuildSecondaryIndexDefs runs during plan-tree construction for CREATE INDEX (pkg/sql/plan/build_ddl.go:2081 dispatch). It returns the per-hidden-table IndexDef and TableDef pair that pkg/sql/compile will later create on disk.
The IndexDef list and TableDef list must align positionally — one entry per hidden table. For IVF-PQ that is two: a small metadata table (mo_secondary_metadata_xxx — index_id, checksum, timestamp, filesize), and a chunked storage table (mo_secondary_index_xxx — the serialized index payload split into blob chunks). The TableType field is what CatalogHooks.HiddenTableTypes() returned earlier; the framework keys downstream maps by this.
Helpers available from planplugin (populated by pkg/sql/plan's init):
planplugin.CreateIndexDef — constructs the *plan.IndexDef
(serializes algo params from
indexInfo.IndexOption into JSON)
planplugin.MakeHiddenColDefByName — builds a hidden composite-PK
placeholder column (used for the
storage table's compound PK)
planplugin.ValidateIncludeColumns — validates INCLUDE column list
against colMap + pk constraints
Lifted from pkg/sql/plan/build_ddl.go:3114-3353 (the deleted buildIvfpqSecondaryIndexDef).
func (Hooks) CanApply ¶
func (Hooks) CanApply(pb planplugin.PlanBuilder, vctx *planplugin.VectorSortContext, mti *planplugin.MultiTableIndexRef) (bool, error)