Skip to content

[core] Support centroid-sharded vector global indexes - #1491

Merged
JingsongLi merged 7 commits into
apache:mainfrom
JingsongLi:codex/centroid-vector-sharding
Nov 22, 2026
Merged

JingsongLi merged 7 commits into
apache:mainfrom
JingsongLi:codex/centroid-vector-sharding

Conversation

@JingsongLi

@JingsongLi JingsongLi commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Part of #1490. Align Rust Data Evolution vector indexes with the centroid layout introduced by apache/paimon#11249.

Brief change log

  • Read and write Java-compatible PAIMCENT descriptors and PVROUT01 routing models. Build local indexes over sparse row labels relative to their source range and atomically replace the selected partitions' index files.
  • Route single and batch queries with centroid.nprobe, automatic widening, and shard-local IVF or DiskANN options. Check manifest generation completeness at commit and query time.
  • Train one router per maximal contiguous source range and cap explicit local IVF lists at the shard's training sample count. Apply deletion-vector masks before routing and give residual post-filters one candidate budget per routed range.
  • Keep centroid refresh explicit. The Rust builder spills batches to local scratch files and trains each local index independently. Outer and inner probe widths use independent policies.

Tests

  • A Java JNI fixture verifies model and native shard reads with rebased labels.
  • A Rust end-to-end test covers range-to-centroid replacement, serialized build plans, routed batch queries, and rebuilding the same partitions.
  • Additional Rust and Python regressions cover filtered replacement, empty routers, live-row candidate budgets, and commits from transported build plans.

API and Format

Adds centroid build and search options and a build-plan accessor for the index removals that accompany a replacement. Existing range indexes retain their format.

Documentation

Documents explicit centroid builds, replacement, and probe options. Draft for review of the routing and manifest assumptions.

@JingsongLi
JingsongLi marked this pull request as ready for review November 22, 2026 05:19

@leaves12138 leaves12138 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full diff at head ccdd72f against main (29 files, +2365/-83), cross-checked against the Java contracts in CentroidIndexMeta, VectorTrainingModelIO, and NativeCentroidRoutedIndexReader (apache/paimon#11249 lineage). Part of #1490.

Core / generic semantics touched (flagging per review policy):

  • New on-disk format readers/writers: centroid_index.rs implements the Java-shared PAIMCENT descriptor and PVROUT01 routing model, plus generation grouping/completeness rules used at commit time (index_commit.rs), overlap validation, and query planning. This is a cross-language storage contract.
  • Generic index build/commit plumbing: GlobalIndexBuildPlan.replacement_messages() (new public API, also exposed through the Python binding), PartitionFilter::matches_entry_for_removal, spill/route/partition refactor in index_build/vector.rs, and auto-index maintenance now standing down for routed columns (auto_index/planning.rs).
  • Generic vector query path: de_vector_read.rs renames the file-work executor, adds centroid planning/routing (de_vector_read/centroid.rs), applies deletion-vector live-row masks before routing, strips deleted rows before reranking, and adds the vector-index-centroid distributed task kind; vector_search_common.rs and search_scan_split.rs learn empty-router semantics.

What I verified:

  • Format compatibility: descriptor header is 22 bytes (magic + version + role + 3 big-endian i32), matching Java CentroidIndexMeta.wrap byte-for-byte including the -1 absent-payload sentinel; version/role pairs (1|2 router/shard, 2 bitmap) match Java's VERSION/SCALAR_INDEX_VERSION gates. Router envelope is big-endian length + camelCase JSON (version/shardMode/modelId, "centroid-based") with the 65536 envelope cap, matching VectorTrainingModelIO; the PVROUT01 payload is little-endian dim/nlist/metric with metric codes 0/1/2 = l2/inner_product/cosine, matching legacyMetric. The Java-written binary fixture (router + two IVF-FLAT shards) is read end-to-end with labels rebased to range [2,5], and an out-of-range native label is rejected.
  • Routing parity: automatic_width matches Java automaticWidth (floor 3/4/8 for nlist 4/8/other, ceil(nlist/16) minimum, 4-candidates-per-result budget, inverse-selectivity scaling with u128 avoiding Java's BigDecimal overflow concern, matching==0 -> 1); inner product probes all centroids; automatic doubling widening stops at nlist and is disabled by explicit centroid.nprobe; the DiskANN + ivf.nprobe rejection mirrors Java. Coarse assignment is Euclidean after cosine normalization, consistent with native training.
  • Generation completeness is enforced at both ends: group() requires exactly one router, nlist distinct shards with id < nlist, consistent model/version/source_meta/extra_field_ids, vector_count <= range length, and non-empty generations to have vectors; commit validates groups when centroid deletions are present and folds generations to their routers for overlap validation, so a partial replacement cannot leave a mixed-generation overlap.
  • Replacement atomicity: replacement_messages() groups removals per partition/bucket into deleted_index_files, the plan serializes them (serde(default) keeps old plans loadable), execute() appends them to the built-shard messages in one snapshot-guarded commit, and failed builds abort private outputs. Filtered replacement remaps the predicate to partition fields and fails closed on undecodable partitions (regression covered); untouched partitions survive.
  • DV/live-row semantics: for centroid ranges the deleted-row slack is not added to the index limit; instead local live-row bitmaps restrict candidates before routing (both shared and per-query include sets), and merged results are stripped of deleted rows before reranking. The regression verifies a deleted nearest neighbor does not consume the Top-1 budget, identically on the local and transported-executor paths.
  • Distributed compatibility: centroid_files is serde(default, skip_serializing_if empty) and the new task kind vector-index-centroid makes older workers reject rather than silently ignore routed work, following the existing vector-index-filtered pattern; empty routers do not define raw-scoring metric/type (regressions cover the raw fallback for appended rows).
  • Build path: one router per maximal contiguous range (rows_per_shard effectively unbounded for centroid builds), router trained via IVF-FLAT with exact coarse assignment, per-centroid spill partitions preserve input row order, local nlist capped at the shard's training sample count, empty centroids write the PCEMPTY1 sentinel with row_count 0, and outer-only options (sharding, centroid.nlist, DiskANN's outer train cap) are stripped from native shard options. Auto range maintenance stands down when the column is routed, preventing partial rebuilds from retiring routed siblings.

No findings. CI is fully green at this head (15/15 checks). The PR description still says "Draft for review" but the PR is marked ready; assuming that line is stale.

@JingsongLi
JingsongLi merged commit fe8244b into apache:main Nov 22, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants