Skip to content

[core] Read incremental centroid index batches with a shared router - #1586

Open
shyjsarah wants to merge 3 commits into
apache:mainfrom
shyjsarah:feat/centroid-batch-offsets
Open

shyjsarah wants to merge 3 commits into
apache:mainfrom
shyjsarah:feat/centroid-batch-offsets

Conversation

@shyjsarah

@shyjsarah shyjsarah commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

A Java writer can append a batch of vector shards using the existing centroid router. Searching that table with Rust previously failed with Centroid generation has no routing model. This change also covers PyPaimon's native search and plans sent to separate workers.

Companion to apache/paimon#11674. Part of #1490.

Brief change log

Resolve each batch's router from its partition, bucket, index type, field and the batch start minus the shard offset. Validate native shard metadata and Bitmap files against their actual batch. A centroid can have several physical shard files in one batch. Probe all of them with the same batch-local Bitmap filter and merge their hits before Top-K. The reader uses the batch range to localize filters, restore row IDs and merge results. A standalone index split includes the physical router and its batches, while coverage follows the actual ranges and preserves gaps.

Tests

The Java fixture has one router at row 1, an unindexed vector at row 3, and an appended batch with two files for centroid 0. Different workers built the files from two snapshots separated by an unrelated append. Their native labels 0 and 2 map to table rows 4 and 6. Each Bitmap supplies the schema used to read it. The table is packaged in the existing centroid-java.tar.gz interop fixture. Regression cases cover fast and detail searches, Bitmap filtering, Top-1 with scores, and transporting the plan. Commit tests cover retiring an appended batch and protecting the router while another batch depends on it.

The review follow-up passed 19 centroid unit tests, four index-commit tests and all three Java interop reader tests. The paired PyPaimon wheel passed 47 native vector layout tests and read the Java multi-file table through local and transported plans.

API and Format

Reads the optional eight-byte big-endian shard offset defined in the companion Java PR. Offset-zero shards use the existing encoding. Public build and query APIs retain their signatures.

Documentation

The centroid fixture README describes the shared-router table and expected batch coordinates.

@shyjsarah shyjsarah changed the title [core] Read centroid batches that share a routing model [core] Read incremental centroid index batches with a shared router Dec 4, 2026

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The Java shared-router layout has concrete interoperability value. I reviewed 3b07dfe3 on current main 2456fee3 and ran 5,205 core tests and 3 Java interop tests in a detached worktree. The Java fixture returned row 6 with score 1.0 through both local search and serialized worker execution. Two additional checks found the compatibility and storage I/O issues below.

let file_meta = file.global_index_meta.as_ref().unwrap();
if file.file_size < 0
|| file.row_count < 0
|| ((offset == 0 || require_same_source) && file_meta.source_meta != meta.source_meta)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Read the initial batch when its files were built at different snapshots. I changed only one initial shard’s source snapshot from 1 to 2 in the Java-written MyTable fixture. Snapshot 2 is an index-only commit with the same data. The otherwise identical shared-router table now fails in plan() with Incomplete or conflicting centroid generation, including for a query targeting the appended range. The companion Java commit validates each wrapped file against changes to its indexed rows, so independently staged files can share a batch when intervening snapshots leave those rows intact. Apply source equality only to Rust-generated additions, and add an interop case covering mixed provenance in the initial batch. Java commit validation

.map(|group| {
let mut files = group.files.into_iter().cloned().collect::<Vec<_>>();
if group.anchor != group.router {
files.push(group.router.clone());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Reuse the decoded router across batches in a local query. I traced Router::load while running one local Top-1 search on the Java fixture. The same router path was fully read twice, once for each populated batch. Each local task reads and decodes the model again. With the default local cache setting and 16 batches sharing a 64-center, 1,536-dimensional model, a query would read the same roughly 384 KiB router 16 times over object storage. Share one in-flight load and decoded model per physical router within the local query. The serialized tasks can still carry the model reference for independent workers.

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