[core] Add primary-key vector index foundation#8549
Conversation
leaves12138
left a comment
There was a problem hiding this comment.
I found one blocking schema-evolution issue. The five focused vector-index test classes pass locally (47 tests), but a SchemaManager-level column-rename reproduction fails with IllegalArgumentException: Field embedding can not be found in table schema. The PK-vector option keys and column registry need to participate in the real rename path before this can be merged.
leaves12138
left a comment
There was a problem hiding this comment.
The top-level rename path is fixed and the focused suite passes locally (48 tests), but one supported field-qualified JSON option case still changes the vector index definition ID after a column rename. I added an inline reproduction below.
leaves12138
left a comment
There was a problem hiding this comment.
The rename restriction looks good, but the latest ANN build API simplification drops a source-cardinality invariant and can create metadata that the searcher refuses to read. I left one inline comment.
leaves12138
left a comment
There was a problem hiding this comment.
I found one correctness issue in the rebuilt ANN segment metadata. The focused regression assertion reproduces it consistently.
leaves12138
left a comment
There was a problem hiding this comment.
Re-reviewed the latest head. The inclusive row-range issue is fixed, empty source rows are rejected, and the focused 50-test suite passes locally. LGTM.
Builds the bucket-local maintenance layer for primary-key vector indexes on top of #8549. The maintainer restores active ANN state, reads complete vectors from compact data files, and produces index-file increments for compaction transitions without activating the write or query paths yet.
Summary
Introduce the foundation for bucket-local vector indexes on primary-key tables. This PR defines the table-option and validation contract, ANN payload metadata, and ANN build/search primitives used by later write, compaction, manifest, and query integrations.
This is intentionally a foundation PR: configuring these options does not yet wire end-to-end index maintenance or query routing. Those pieces will be submitted as stacked PRs.
Architecture
The intended data flow is:
The payload uses the actual global-index algorithm as
IndexFileMeta.indexType; there is no syntheticpk-vector-annwrapper type. There is also no persisted RAW vector copy or vector sidecar format: later maintenance code reads the configured vector column directly from complete compact data files. Follow-up maintenance will eagerly build one multi-source ANN for every non-empty set of newly eligible compact sources; there is no row-count grouping threshold.The index stores physical row positions instead of duplicating primary keys. Snapshot visibility is enforced with the deletion vectors of the referenced source files.
Changes
Optionsdirectly throughCoreOptions; no separate primary-key vector options resolver is retained.VECTOR<FLOAT>fields, and supported distance metrics._SOURCE_METAtoGlobalIndexMeta, preserving existing five-field metadata rows assourceMeta=null._INDEX_METAand Paimon-owned ordered source file names and row counts in versionedPkVectorSourceMetaunder_SOURCE_META.IndexFileMeta.indexType; noPkVectorAnnSegmentMetawrapper or synthetic payload type is needed.PkVectorReadercontract so ANN construction is independent of the physical data-file reader introduced by follow-up PRs.VectorGlobalIndexer, support single-source and multi-source ordinals, validate algorithm/metric compatibility, and clean up failed builds.[0, totalSourceRows - 1]and reject source sets with no physical rows.IndexFileMeta.indexType, apply per-source deletion-vector filtering, and map results back to(dataFileName, rowPosition).Table-option API
pk-vector.index.columnsis deliberately plural so each vector field can own one independent index in the future. This first version validates exactly one configured column.ANN construction has no minimum-row option. Once complete compact sources become eligible, later maintenance code will attempt to index them immediately; algorithm-specific build failures are surfaced instead of silently deferring those sources.
No compatibility aliases or payload compatibility paths are retained because this feature has not been released.
Testing
_SOURCE_METAround-trip and legacy five-field Global Index metadata compatibilitymvn -pl paimon-core -Pfast-build \ -Dmaven.compiler.forceJavacCompilerUse=true \ -DwildcardSuites=none \ -Dtest=IndexFileMetaSerializerTest,IndexManifestEntrySerializerTest,ManifestCommittableSerializerCompatibilityTest,PkVectorAnnSegmentFileTest,PkVectorSourceMetaTest,PrimaryKeyVectorIndexOptionsTest,PrimaryKeyVectorIndexValidationTest testNotes
Follow-up stacked PRs will add projected data-file readers, synchronous bucket-level ANN maintenance from compact outputs, manifest restore, exact fallback before eligible compact sources exist, query planning, Top-K merge, and physical-row materialization.