Repository navigation
Conversation
| if (meta != null && rowIdOffset(meta.indexMeta()) != 0) { | ||
| appended.add(Arrays.asList(file.indexType(), meta.indexFieldId(), meta.rowRange())); | ||
| } | ||
| } |
There was a problem hiding this comment.
Nit: Because an appended centroid batch can have up to nlist shard files sharing the same (indexType, indexFieldId, rowRange), using a List<List<Object>> for appended appends a duplicate entry per shard and then performs a linear appended.contains(...) scan for every wrapped file. Using a Set<List<Object>> (with an early return when appended.isEmpty()) avoids duplicate entries and keeps the lookup
public static List<IndexFileMeta> withoutAppendedBatches(Collection<IndexFileMeta> files) {
Set<List<Object>> appended = new HashSet<>();
for (IndexFileMeta file : files) {
GlobalIndexMeta meta = file.globalIndexMeta();
if (meta != null && rowIdOffset(meta.indexMeta()) != 0) {
appended.add(Arrays.asList(file.indexType(), meta.indexFieldId(), meta.rowRange()));
}
}
if (appended.isEmpty()) {
return new ArrayList<>(files);
}
List<IndexFileMeta> result = new ArrayList<>(files.size());
for (IndexFileMeta file : files) {
GlobalIndexMeta meta = file.globalIndexMeta();
if (meta == null
|| !isWrapped(meta.indexMeta())
|| !appended.contains(
Arrays.asList(
file.indexType(), meta.indexFieldId(), meta.rowRange()))) {
result.add(file);
}
}
return result;
}There was a problem hiding this comment.
Fixed in 3cb34f3c06. Changed appended to a HashSet, added the empty-set early return, and pre-sized the result list. The returned files retain their original order.
| partitionFilter, | ||
| CentroidIndexMeta.withoutAppendedBatches(coverageIndexFiles), | ||
| searchMode, | ||
| schema); |
There was a problem hiding this comment.
Nit: DataEvolutionGlobalIndexCoverage's constructor already wraps indexFiles with CentroidIndexMeta.withoutAppendedBatches(indexFiles) (line 84 of DataEvolutionGlobalIndexCoverage.java), so calling CentroidIndexMeta.withoutAppendedBatches(coverageIndexFiles) here filters coverageIndexFiles twice.
There was a problem hiding this comment.
Fixed in 3cb34f3c06. Removed the extra filtering of coverageIndexFiles in the scanner constructor; DataEvolutionGlobalIndexCoverage handles it. The scanner still filters its reader input separately.
| || CentroidIndexMeta.isShard(meta.indexMeta())) | ||
| || deletedIndexes.contains(file.fileName())) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
Nit: For the initial batch (rowIdOffset == 0), the routing model already carries the batch's rowRange and extraFieldIds, so matching CentroidIndexMeta.isShard(meta.indexMeta()) re-runs the partitionUpdates loop for all nlist shards of the first batch as well. Matching CentroidIndexMeta.rowIdOffset(meta.indexMeta()) != 0 (consistent with checkCentroidSourceChanges at line 733) avoids checking every shard of the first batch when its routing model is already checked.
There was a problem hiding this comment.
Fixed in 3cb34f3c06. The condition now selects routing models or files with a nonzero rowIdOffset, avoiding repeated checks for initial-batch shards. Added a regression covering initial and appended batches: unrelated-column updates remain allowed, and updates to retained Bitmap fields are still rejected.
| checkCentroidRouters(snapshot, indexFiles); | ||
| if (commitKind == CommitKind.COMPACT || snapshot.indexManifest() == null) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Nit: When a commit includes both appended centroid shards and deltaFiles updates, checkCentroidRouters reads indexFileHandler.readManifest(current.indexManifest()) (line 822) and checkRetainedGlobalIndexes reads indexFileHandler.readManifest(snapshot.indexManifest()) a second time (line 331). Sharing the lazily loaded manifest list between the two checks would avoid reading the current index manifest twice in the same checkRetainedGlobalIndexes call.
There was a problem hiding this comment.
Fixed in 3cb34f3c06. Both checks now share a method-local LazyField for the current manifest. It loads only when needed and is recreated on each call, so commit retries read the current state again.
Extended the retry regression to cover commits with and without data updates, verifying one shared current-manifest read and detection of a Router change on retry. All 187 focused Java tests passed, with Checkstyle, Spotless and Enforcer enabled.
JingsongLi
left a comment
There was a problem hiding this comment.
The 200 focused Java tests passed on this head. Additional checks reproduced failures in row-ID reassignment, deferred scalar reads, and PyPaimon native vector search. The inline comments include the failing cases and two places where work or memory grows with the batch count.
| for (IndexManifestEntry entry : batches.get(range)) { | ||
| byte[] descriptor = entry.indexFile().globalIndexMeta().indexMeta(); | ||
| if (isRoutingModel(descriptor) || isShard(descriptor)) { | ||
| long candidate = range.from - rowIdOffset(descriptor); |
There was a problem hiding this comment.
[P1] Recompute shard offsets during row-ID reassignment
reassign_row_id rewrites each manifest range and copies the shard descriptor unchanged. With an interleaved partition, the router at row ID 0 and an appended batch at 2 can move to 3 and 4. Subtracting the stored offset of 2 from 4 leaves the shard pointing at row ID 2. I reproduced Missing centroid routing model on both vector search and an attempt to drop the index, since the combiner validates the previous manifest.
Recompute each dependent shard's offset from the remapped batch and router starts. If the router cannot be remapped, retire its dependent batches atomically. Reassignment manifest rewrite
There was a problem hiding this comment.
Reassignment now recomputes the offset from the new batch and router starts and retires dependent batches if their router cannot be mapped. In the interleaved-partition test, the offset changes from 2 to 1. A new scan returns rows 3 and 4, the pinned scan still returns 0 and 2, and dropping the index succeeds. 7e79192ebe · Regression test
| DataEvolutionIndexSchema schema) { | ||
| this.table = table; | ||
| this.indexFiles = new ArrayList<>(indexFiles); | ||
| this.indexFiles = CentroidIndexMeta.withoutAppendedBatches(indexFiles); |
There was a problem hiding this comment.
[P1] Apply the appended-batch filter to deferred scalar queries
With global-index.query-in-reader.enabled=true, a regular WHERE embedding IS NOT NULL read against a vector-only centroid index goes through GlobalIndexQuery.create, which calls groupIndexFiles directly. The appended range becomes a shard-only group, causing the deferred reader to throw Missing routing model before it can fall back to scanning the data. I reproduced this with one appended batch.
Apply the same index eligibility filter at the grouping entry point shared by both scalar paths and add a deferred-reader regression. Deferred query grouping
There was a problem hiding this comment.
The deferred scalar reader and the planner now use the same scalar index eligibility check. For a vector-only centroid index, WHERE v IS NOT NULL falls back to the data scan. The regression runs both FAST and FULL and returns all four rows in each mode. 7af263ce40 · Regression test
| } | ||
| file = | ||
| new ResultEntry( | ||
| file.filePath(), file.rowCount(), out.putLong(rowIdOffset).array()); |
There was a problem hiding this comment.
[P1] Keep shared-router batches readable by PyPaimon
The current Rust reader groups index files by their manifest row range and requires a router in each group. After a Java writer commits its first nonzero-offset batch, PyPaimon's native vector query fails with Centroid generation has no routing model. I reproduced this with real IVF-FLAT files and a manifest using the shared-router layout. PyPaimon's commit guard also checks only router ranges, so with global-index.column-update-action=IGNORE it misses updates to indexed Bitmap fields in an appended batch.
Add shared-batch support to native search and retained-index validation before enabling nonzero-offset writes on tables that PyPaimon can access. Rust grouping · PyPaimon commit guard
There was a problem hiding this comment.
PyPaimon’s commit guard now checks the Bitmap fields of appended batches. The Java-table regression verifies that updating an indexed field with IGNORE fails without advancing the snapshot, while updating an unrelated field succeeds. The companion Rust reader also passed native PyPaimon searches on that table, including Bitmap filtering and a serialized plan. 2c7e20cef7 · PyPaimon regression · apache/paimon-rust#1586
| RoaringNavigableMap64 matches = new RoaringNavigableMap64(); | ||
| for (Map.Entry<Long, IOFunction<Integer, RoaringNavigableMap64>> batch : | ||
| filters.entrySet()) { | ||
| for (long row : batch.getValue().apply(centroid)) { |
There was a problem hiding this comment.
[P2] Build Bitmap include IDs for one batch at a time
The native reader invokes this callback for every shard of a selected centroid. With B populated batches, each invocation rebuilds matches from all B batches. This copies matching row IDs B times and makes filtering work grow quadratically for fixed-size batches. Each shard's filter can also serialize IDs belonging to later batches.
Pass the batch identity alongside the centroid, return that batch's local Bitmap matches, and clip any query-wide include IDs to the batch before serializing. Per-shard callback
There was a problem hiding this comment.
The native reader now looks up Bitmap matches for the shard’s own batch and clips query-wide include IDs to that batch before serialization. The IVF-FLAT and IVF-PQ tests use sparse IDs across two batches and check which shard files are opened when only one batch can match. 7e79192ebe · Native reader regression
| DataEvolutionIndexSourceMeta.fromIndexFile(entry.indexFile()).scanSnapshotId(); | ||
| checkState(baseline <= current.id(), "Invalid centroid routing model source snapshot."); | ||
| List<IndexManifestEntry> source = | ||
| centroidBaselines.computeIfAbsent( |
There was a problem hiding this comment.
[P2] Limit the source-manifest cache to a logical commit
A long-lived StreamTableCommit reuses the same conflict detector. Appending batches built against successive source snapshots keeps a separate full index manifest in centroidBaselines for every snapshot, even after it expires. With a fixed number of shards per batch, the total number of retained manifest entries grows quadratically with the number of appends.
Scope the cache to a logical commit and its retries, and keep only the router identities needed by the check.
There was a problem hiding this comment.
The cache now lives for one logical commit and its retries. Only the requested source router identities survive an attempt. Each retry reads the current manifest again, so it detects a concurrent router replacement even when the source identity is cached. The test also covers a retry after the source snapshot expires. 7e79192ebe · Retry regression
JingsongLi
left a comment
There was a problem hiding this comment.
I followed up on the row-ID range checks in the commit path. Local Java tests reproduced both the stale router binding when a rebuild and append share one commit and the failure when range sort retires the shared router. The inline comments also cover repeated range checks for retained Bitmap indexes.
| } | ||
| IndexFileMeta currentRouter = routerFor(entry, retained.get()); | ||
| IndexFileMeta newRouter = routerFor(entry, added); | ||
| if (newRouter != null && !sameRouter(newRouter, currentRouter)) { |
There was a problem hiding this comment.
[P1] Validate the build-time router for each appended range
A new router at the same origin can belong to a different build. TableCommitImpl can publish an index rebuild and an independently prepared append in the same commit, so this branch skips validation for shards built against the old router. I reproduced this with a two-centroid router for [0, 0] and a shard for the disjoint batch [1, 1] using centroid 1. Replacing the router with a one-centroid model in the same commit succeeded, and the next vector query failed with Invalid shard centroid 1.
Require the shards for each batch range to agree on their build-time router identity and compare it with the router that will survive the commit's additions and deletions. A complete rebuild can declare the new router's identity for all its batches.
There was a problem hiding this comment.
The committer now checks the build-time router of each appended shard and Bitmap against the router that will survive the commit. The regression rejects a mixture of old and rebuilt shards in either order. A coordinated rebuild can declare the replacement router for all its batches. 34dbf55d61 · Mixed-router regression
| entry -> | ||
| indexEntries.containsKey( | ||
| entry.indexFile().fileName())), | ||
| "Cannot remove centroid routing model while dependent files remain."); |
There was a problem hiding this comment.
[P1] Include dependent batches when range sort retires a router
sort_data_evolution selects index files for retirement when their own row-ID range intersects the rewritten input range. With a router in [0, 1] and a dependent batch in [2, 3], sorting [0, 1] schedules the router for retirement and leaves the dependent shard out of the retirement set. This check then blocks the sort commit. I reproduced the failure through dataEvolutionRangeSortCheck. The same sort completed when each range had its own router.
On each commit attempt, expand the range-based retirement set to include dependent batches whenever it removes their router. Keep the ordinary range check for batches whose router remains live. Range-sort retirement selection
There was a problem hiding this comment.
Range sort now expands the retirement set on each commit attempt. Retiring a router includes its dependent shards and Bitmaps, including a batch added before a retry. When the router survives, retirement is still limited to batches that intersect the sorted range. 34dbf55d61 · Range-sort retry regression
| || !CentroidIndexMeta.hasBitmapFields(meta) | ||
| || !CentroidIndexMeta.isRoutingModel(meta.indexMeta()) | ||
| || !(CentroidIndexMeta.isRoutingModel(meta.indexMeta()) | ||
| || CentroidIndexMeta.rowIdOffset(meta.indexMeta()) != 0) |
There was a problem hiding this comment.
[P2] Check retained Bitmap updates once per batch range
This walks the partition's update list for every nonzero-offset shard. An appended batch with 256 populated centroids can repeat the same row-ID overlap and indexed-field checks 256 times, including for a backfill that touches only an unrelated column.
Group retained entries by partition, bucket, index definition, and actual batch range. Check each batch's indexed fields once, using the intersecting update ranges. The index builder already writes the same batch range and indexed field IDs to sibling shards.
There was a problem hiding this comment.
Retained Bitmap checks now group sibling shards by partition, bucket, index definition and batch range. The regression counts the update checks with two sibling shards and separately verifies that each indexed Bitmap field is protected. 34dbf55d61 · Regression test
JingsongLi
left a comment
There was a problem hiding this comment.
I re-ran the focused Java suites on this head and checked index builds that cross row-ID reassignment. The inline comment covers a stale Bitmap that can be published and a valid append that is rejected.
| range.from > routerStart.from, | ||
| "Cannot rebase centroid batch before its router."); | ||
| descriptor = | ||
| CentroidIndexMeta.rebaseShard(descriptor, range.from - routerStart.from); |
There was a problem hiding this comment.
[P1] Validate rebased batches in each snapshot's row-ID space
After rebasing, the manifest entry carries the new range and offset, while its build snapshot still uses the original row IDs. I reproduced both outcomes with the Java commit path.
- A staged shared batch at row
2rebases to row4, and its retained router moves from0to3. The append is rejected because the source-manifest lookup searches for the router at3in the pre-reassignment snapshot, even though the router file is unchanged. - With a complete staged group, an indexed Bitmap column can change at old row
2before reassignment. Historical validation compares that update with the rebased range at4and misses the conflict. The stale group commits, and a vector query filtered by the new value omits the updated row. Without reassignment, the same update correctly causes the index commit to be rejected.
Keep the original batch range and router origin for source validation. Advance the ranges through the reassignment history in snapshot order so each delta is checked in its own row-ID space, then validate the router binding in the final manifest. Source changes check · Source router lookup
There was a problem hiding this comment.
Source router lookup now uses the original row IDs, and each intervening update is checked in the row-ID space of its own snapshot. The regression stages an append across two reassignments. The valid append remains searchable at its final row ID, and an indexed-field change before, between or after the reassignments rejects the stale build without advancing the snapshot. 7af263ce40 · Regression test
JingsongLi
left a comment
There was a problem hiding this comment.
I re-ran the focused Java suites on this head. The two new inline findings cover the paired Rust reader's handling of multiple files per centroid and an appended batch omitted by deferred scalar FAST.
| assertThat(table.snapshotManager().latestSnapshotId()).isEqualTo(before); | ||
| assertThat(query("fast").executeLocal().results()).containsExactly(0L, 1L); | ||
| commit( | ||
| Arrays.asList(oldShard, shardInBatch(2, 3, 3, original.get(0))), |
There was a problem hiding this comment.
[P1] Support multiple shard files for one centroid in Rust
This positive case publishes two files for centroid 0 in the same [2, 3] batch. The files contain disjoint row IDs, and Java returns all four rows. The paired Rust reader stores one shard per centroid per batch and rejects the second file with Incomplete or conflicting centroid generation. That validation runs when planning both local and transported queries, including unfiltered queries.
Please make the companion reader retain and search all shard files for a centroid within a batch, and add this Java-generated layout to the cross-runtime regression fixtures. Rust batch validation
There was a problem hiding this comment.
The Rust reader now searches every file for the selected centroid within a batch and merges their hits before Top-K. The existing Java interop fixture includes two files for centroid 0 in the same appended batch. FAST returns rows 1, 2, 4 and 6, the Bitmap predicate returns only row 6, and a transported Top-1 plan also returns row 6. apache/paimon-rust#1586 · Java interop regression
| Collection<IndexFileMeta> indexFiles) { | ||
| Map<List<Integer>, IndexMetaFileGroup> primaryGroups = new LinkedHashMap<>(); | ||
| for (IndexFileMeta indexFile : indexFiles) { | ||
| for (IndexFileMeta indexFile : CentroidIndexMeta.withoutAppendedBatches(indexFiles)) { |
There was a problem hiding this comment.
[P2] Keep unsupported vector indexes out of scalar FAST pruning
The initial centroid vector batch still reaches GlobalIndexQuery after the appended files are removed. With global-index.query-in-reader.enabled=true and scalar-index.search-mode=fast, the planner uses that group's coverage to prune data splits before the reader can decline the scalar predicate. I reproduced WHERE v IS NOT NULL on four non-null rows in shared batches [0, 1] and [2, 3]. Deferred FAST returns rows 0, 1. Eager FAST and the deferred control with one router per batch both return all four.
Exclude vector-only centroid definitions from scalar eligibility and coverage so unsupported predicates retain the full data-scan fallback. Add FAST to the existing deferred scalar regression. Deferred FAST pruning
There was a problem hiding this comment.
Both the initial and appended centroid files are now excluded from scalar index coverage. With deferred FAST enabled, WHERE v IS NOT NULL keeps both data ranges and returns rows 0, 1, 2 and 3. The regression checks coverage as well as the final rows. 7af263ce40 · FAST regression
JingsongLi
left a comment
There was a problem hiding this comment.
I tested 7af263ce40 merged with 055fe60215. The local run passed 125 Java vector tests, 25 Spark centroid tests, and the focused PyPaimon commit cases. The Rust companion at 3b07dfe3 passed its three Java interop tests, including sparse batches and a transported plan. Rust companion
[P2] Keep FAST liveness checks inside the actual indexed batch ranges. I built a Data Evolution table with indexed batches [0,1] and [4,5] and an unindexed gap [2,3] containing a deletion vector. After removing only that gap deletion vector in the fixture, the independent-router FAST plan still returned rows 0, 1, 4, and 5. The shared-router plan failed trying to open the gap file. Using the split envelope for liveness also adds unnecessary I/O when all files are healthy. Use the batch-range union for liveness and scalar filtering, and keep the envelope for row-ID translation. Shared-router split
[P2] Check each retained Bitmap batch once during Python commits. Updating the unrelated note column in row 6 of the Java fixture ran the same indexed-field check twice, once per sibling shard. The new retained-entry filter admits every offset-bearing shard, multiplying the per-update work by the number of shards in a populated batch. Please deduplicate by partition, bucket, index definition, and batch range while retaining its indexed field IDs, as the Java guard does. Python commit guard
[P2] Document the Java rollout and downgrade requirements. An older Java planner groups files by their exact manifest range. It fails to find the router for an appended range even though the descriptor still uses version 1. Upgrade Java readers with the matching vector plugin and deploy a Rust runtime containing #1586 on PyPaimon coordinators and workers before publishing nonzero offsets. Retire or rebuild shared-router indexes before downgrading readers that need to access those snapshots. Compatibility guide
Purpose
Allow appended centroid-index batches on Data Evolution tables to reuse one router. Each shard carries a
rowIdOffset; its router origin isbatchStart - rowIdOffset. A query searches every file of the selected centroids, restores row IDs before Top-K merging, and translates filters in the opposite direction.The current centroid descriptor keeps its version and adds only an optional 8-byte shard offset, omitted at zero. Native router/vector bytes and the existing row-range metadata are reused. Actual batch ranges provide coverage, including gaps and all-null ranges. Existing Spark and PyPaimon builds continue to emit zero offsets.
The table path groups batches by router origin and preserves per-batch Bitmap filtering and snapshot reads. On every commit attempt, each new shard and Bitmap in an appended range must match the router that will survive the commit. Ordinary appends use the source snapshot. A coordinated rebuild can declare its new router when staging the batch, and the committer strips that declaration before writing the manifest. Full-batch replacement uses the existing commit rules. Spark Bitmap-field add/drop procedures require rebuilding shared-router groups.
Row-ID reassignment recalculates offsets and retires batches whose router can no longer be mapped. The committer looks up each staged file’s source router at its original row ID, checks updates in the row-ID space of each snapshot, and verifies the surviving router at its final row ID. Replacing a batch through an index-only compaction also checks the build snapshot of each new file. Scalar FAST planning and deferred reads exclude centroid vector files from scalar index coverage and fall back to scanning the data. Bitmap filtering and include-ID serialization now use the actual batch range. Only requested source router identities are cached across retries of a single commit. A range sort that retires a router also retires its dependent batches, including those added before a retry. Updates to retained Bitmap indexes are checked once per bucket, index definition and batch range.
Python commits protect indexed Bitmap updates and complete-batch retirement on existing shared-router tables. The paired Rust reader supports local and transported PyPaimon queries. The companion change is apache/paimon-rust#1586.
Tests
CentroidVectorIndexTestcases. Regressions cover a valid incremental append across two row-ID reassignments, independently built stale shards and Bitmaps, an index-only compaction replacement, commit retries, and deferred scalar FAST queries on a shared router.fast-build; Checkstyle, Spotless, Enforcer and RAT checks passed.Local IVF-PQ measurements before per-batch filter clipping
Apple M4 Pro, JDK 11, local files; identical 16,384-row 8D corpus and router, four centroids probed, local nlist=1, PQ m=2. Each case uses 16 warmups and 64 sequential queries, four file-read workers, 100 candidates and exact in-memory refinement to top-10 inside the timed interval. The include-ID filter selects 2,048 rows in the last quarter of the corpus.
These reuse-reader measurements open the router once during warmup. Fresh-reader unfiltered P95 was 0.378 / 1.179 / 2.258 ms for 1 / 8 / 16 batches, with one router open per query. OS cache is uncontrolled; this is not a disk-cold or object-store benchmark. Raw-vector fetch I/O, physical Bitmap predicate I/O and table planning are excluded. This earlier measurement used only the offset when filtering. The current implementation clips to the batch end from the manifest and skips files whose range has no included IDs. These timings have not been remeasured after that change. The results illustrate file fanout at comparable recall, not a production compaction threshold.