compile

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: 13 Imported by: 0

Documentation

Overview

Package compile implements the CAGRA plugin's compile-layer (DDL) hooks. See pkg/vectorindex/ivfpq/plugin/compile for the canonical template.

Lifted from:

  • pkg/sql/compile/ddl_index_algo.go:732 (handleVectorCagraIndex)
  • pkg/sql/compile/util.go:666,688 (gen{Delete,Build}CagraIndex)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hooks

type Hooks struct{}

Hooks implements plugin/compile.Hooks for CAGRA.

func (Hooks) HandleCreateIndex

func (h Hooks) HandleCreateIndex(ctx compileplugin.CompileContext, indexDefs map[string]*plan.IndexDef) error

HandleCreateIndex is lifted from Scope.handleVectorCagraIndex (pkg/sql/compile/ddl_index_algo.go:732).

The sync-vs-async branch is driven by the index's `async` IndexAlgoParam (catalog.IsIndexAsync). Default (key missing or "false"): forceSync=true — cagra_create runs inline in the user's CREATE INDEX txn before the CDC task is registered. Explicit async="true": forceSync=false — the build SQL is stashed as ConsumerInfo.InitSQL and runs at the first CDC iteration.

func (Hooks) HandleDropIndex

func (Hooks) HandleDropIndex(_ compileplugin.CompileContext, defs map[string]*plan.IndexDef) error

HandleDropIndex is a no-op: generic hidden-table cleanup is sufficient.

func (Hooks) HandleReindex

func (h Hooks) HandleReindex(ctx compileplugin.CompileContext, indexDefs map[string]*plan.IndexDef, forceSync bool) error

HandleReindex runs the same code path as create, but honors forceSync. The idxcron background reindex executor passes forceSync=true so the build happens synchronously inside the txn before the CDC task picks up forward changes. Mirrors IVF-FLAT.

func (Hooks) IdxcronMetadata

func (Hooks) IdxcronMetadata(ctx compileplugin.CompileContext) ([]byte, error)

IdxcronMetadata pins CAGRA's build-time params into the cron task's metadata blob so the periodic rebuild uses the values the user picked at CREATE INDEX (not whatever the system vars happen to be when the cron fires hours/days later). Background re-entry is gated by BuildIdxcronMetadata's ctx.IsFrontend() check.

func (Hooks) RestoreInitSQL

func (Hooks) RestoreInitSQL(ctx compileplugin.CompileContext, indexDefs map[string]*plan.IndexDef) (bool, string, error)

RestoreInitSQL returns the CDC InitSQL that rebuilds the CAGRA index from the cloned rows during restore — run post-commit by the CDC's first iteration (ProcessInitSQL), so it sees the committed clone and re-arms the CDC at the post-clone watermark. See Scope.RestoreTable.

func (Hooks) ValidateReindexParams

func (Hooks) ValidateReindexParams(old map[string]string, alter compileplugin.ReindexParamUpdate) (map[string]string, error)

Jump to

Keyboard shortcuts

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