plan

package
v0.0.0-debug-20260702 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package plan implements the HNSW plugin's plan-layer hooks.

Phase 6 split: bodies for ANN rewrite (CanApply, ApplyForSort) live in pkg/sql/plan/apply_indices_hnsw.go as methods on *QueryBuilder. Plugin Hooks are thin one-line redirects via the planplugin.PlanBuilder facade. Hidden-table schema (BuildSecondaryIndexDefs in schema.go) and the hnsw_create / hnsw_search table-function builders (tablefunc.go) stay here.

Index

Constants

View Source
const (
	HNSWCreateFuncName = "hnsw_create"
	HNSWSearchFuncName = "hnsw_search"
)

Variables

View Source
var (
	HNSWSearchColDefs = []*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

ApplyForSort redirects to (*plan.QueryBuilder).ApplyIndicesForSortUsingHnsw.

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 hnsw — 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 constructs the IndexDef + TableDef pair for the two hidden tables HNSW requires (metadata + storage). Lifted from pkg/sql/plan/build_ddl.go:2810 (buildHnswSecondaryIndexDef, now deleted).

Differs from CAGRA/IVF-PQ:

  • HNSW supports both T_array_float32 and T_array_float64 (CAGRA/IVF-PQ are float32 only).
  • No INCLUDE columns (no validateIncludeColumns call).
  • The composite-PK column references Cols[3] (Tag), matching the pre-lift behaviour at build_ddl.go:3034.

func (Hooks) CanApply

CanApply redirects to (*plan.QueryBuilder).CanApplyHnsw.

Jump to

Keyboard shortcuts

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