Documentation
¶
Overview ¶
Package runtime holds IVF-FLAT's catalog-side metadata: hidden-table types, parameter schema, op-type set, default options, sync descriptor. See pkg/vectorindex/ivfpq/plugin/runtime for the canonical template.
Lifted from the IVF-FLAT case of catalog.indexParamsToMap (pkg/catalog/secondary_index_utils.go:304-340).
Index ¶
- Constants
- type CatalogHooks
- func (CatalogHooks) AlterTableCloneBehavior() catalogplugin.AlterTableCloneBehavior
- func (CatalogHooks) BuildSessionVars() []string
- func (CatalogHooks) DefaultOptions() map[string]string
- func (CatalogHooks) ExperimentalFlag() string
- func (CatalogHooks) HiddenTableTypes() []string
- func (CatalogHooks) ParamsFromTree(idx *tree.Index) (map[string]string, error)
- func (h CatalogHooks) RestoreBehavior() catalogplugin.RestoreBehavior
- func (CatalogHooks) ShouldTruncateHiddenTable(algoTableType string) bool
- func (CatalogHooks) SupportedIncludeColumnTypes() []types.T
- func (CatalogHooks) SupportedOpTypes() map[string]string
- func (CatalogHooks) SupportedPrimaryKeyTypes() []types.T
- func (CatalogHooks) SupportedVectorTypes() []types.T
- func (CatalogHooks) SyncDescriptor() catalogplugin.SyncDescriptor
Constants ¶
const ( DefaultKmeansTrainPercent = float64(10) DefaultKmeansMaxIteration = int64(20) )
Build-param defaults mirror the frontend session-var defaults; the build path (ivf_create) uses them when the flat algo_params key is absent (a legacy index created before the param was promoted).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CatalogHooks ¶
type CatalogHooks struct{}
CatalogHooks implements plugin/catalog.Hooks for IVF-FLAT.
func (CatalogHooks) AlterTableCloneBehavior ¶
func (CatalogHooks) AlterTableCloneBehavior() catalogplugin.AlterTableCloneBehavior
AlterTableCloneBehavior — IVF-FLAT seeds all three hidden tables during CREATE INDEX on the temp table (a "version=0" metadata row, an initial centroid, and the bootstrapped entries), so the clone loop in cloneUnaffectedIndex must DELETE every target table before copying source rows or each hidden table ends up with the seed duplicated.
Additionally, when the index is async its entries table is rebuilt from ts=0 by the ISCP CDC pipeline on the new table once the index re-registers. Cloning entries AND letting CDC rebuild them produces duplicates, so SkipWhenAsync names entries — but only entries: metadata + centroids still need to be cloned so the CDC sinker has a k-means model to write against.
func (CatalogHooks) BuildSessionVars ¶
func (CatalogHooks) BuildSessionVars() []string
BuildSessionVars returns nil — IVF-FLAT captures no session vars into algo_params, keeping its algo_params byte-compatible with pre-session_vars indexes. Index-defining knobs (k-means) ride flat algo_params keys written by ParamsFromTree only when explicitly set in CREATE INDEX.
func (CatalogHooks) DefaultOptions ¶
func (CatalogHooks) DefaultOptions() map[string]string
DefaultOptions mirrors the IVF-FLAT case of indexParamsToMap when the statement carries no WITH(...) clause: lists=1, op_type=l2.
func (CatalogHooks) ExperimentalFlag ¶
func (CatalogHooks) ExperimentalFlag() string
ExperimentalFlag — IVF-FLAT is NOT gated. The legacy handler on main (Scope.handleVectorIvfFlatIndex) never checked `experimental_ivf_index` at DDL time, so returning "" here preserves that behavior: the gate at pkg/sql/compile/util.go skips when the flag is empty. The variable itself still exists and flows through IdxcronMetadata for downstream consumers.
func (CatalogHooks) HiddenTableTypes ¶
func (CatalogHooks) HiddenTableTypes() []string
HiddenTableTypes — IVF-FLAT uses three hidden tables (metadata, centroids, entries) vs two for HNSW/CAGRA/IVF-PQ. Order is irrelevant; downstream code keys into the map by name.
func (CatalogHooks) ParamsFromTree ¶
ParamsFromTree is lifted verbatim from catalog.indexParamsToMap's INDEX_TYPE_IVFFLAT case (pkg/catalog/secondary_index_utils.go:304-340).
func (CatalogHooks) RestoreBehavior ¶
func (h CatalogHooks) RestoreBehavior() catalogplugin.RestoreBehavior
RestoreBehavior — IVF-FLAT seeds all three hidden tables non-empty at CREATE-INDEX (a version=0 metadata row, an initial centroid, bootstrap entries), and the restore's block-level clone APPENDS. So every hidden table must be emptied with DELETE … WHERE TRUE before the clone re-supplies the snapshot's metadata/centroids/entries — DeleteBeforeClone is the full hidden-table set.
func (CatalogHooks) ShouldTruncateHiddenTable ¶
func (CatalogHooks) ShouldTruncateHiddenTable(algoTableType string) bool
ShouldTruncateHiddenTable — only entries are reset; metadata and centroids preserve the k-means model across TRUNCATE so a subsequent ALTER REINDEX is cheap.
func (CatalogHooks) SupportedIncludeColumnTypes ¶
func (CatalogHooks) SupportedIncludeColumnTypes() []types.T
SupportedIncludeColumnTypes: this index has no INCLUDE-column support.
func (CatalogHooks) SupportedOpTypes ¶
func (CatalogHooks) SupportedOpTypes() map[string]string
func (CatalogHooks) SupportedPrimaryKeyTypes ¶
func (CatalogHooks) SupportedPrimaryKeyTypes() []types.T
SupportedPrimaryKeyTypes: IVF-FLAT imposes no PK-type constraint — the primary key may be any type. nil = "no constraint".
func (CatalogHooks) SupportedVectorTypes ¶
func (CatalogHooks) SupportedVectorTypes() []types.T
SupportedOpTypes returns IVF-FLAT's metric registry. IVF uses a distinct metric table from HNSW/USearch (OpTypeToIvfMetric). SupportedVectorTypes: IVF-FLAT indexes f32 or f64 vectors.
func (CatalogHooks) SyncDescriptor ¶
func (CatalogHooks) SyncDescriptor() catalogplugin.SyncDescriptor
SyncDescriptor — IVF-FLAT uses BOTH:
- ISCP CDC (event-driven; only when the index is async, per IndexAlgoParams), and
- idxcron `ivfflat_reindex` (scheduled rebuild — re-cluster centroids and rebuild entries on the configured cadence).
AlwaysAsync=false: CDC participation depends on the `async` param. Matches the legacy inline behaviour in pkg/sql/compile/iscp_util.go.