perf(index): reuse primary-key index groups with retired source files - #253
perf(index): reuse primary-key index groups with retired source files#253wangyong9999 wants to merge 3 commits into
Conversation
|
The current changes seem reasonable to me. That said, to avoid |
Keep the full immutable source metadata for ordinal localization while covering only eligible sources present in the current scan. Reject conflicting or mismatched active intersections and leave uncovered files on the normal scan path.
cc1ea0d to
9a1f257
Compare
|
Thanks. I narrowed the revision to preserve the existing one-group-per-level lifecycle and added strict |
|
I checked the current Paimon Java and Python readers and confirmed the same exact-active-set rejection there. I filed apache/paimon#9458 and opened the aligned Java/Python fix in apache/paimon#9460. This C++ branch now also binds scan-side source matching to the group's data level, with a regression test for a source moving to another level. |
|
@wangyong9999 I’m not sure this is best described as a bug, since it doesn’t affect correctness and seems more like a performance fallback when the index is not applied. With that in mind, the current title may be slightly misleading. Also, I think it may be better to wait for the Java side to land first before moving this forward, since the Java implementation covers more complex scenarios and the C++ path is currently a subset of that functionality. From what I can tell, the optimization on the C++ side looks reasonable, but I’d feel more comfortable waiting for full validation on the Java side before treating the overall behavior as fully confirmed. Thanks again for the patience here. |
|
Agreed. This is a performance fallback, not a correctness issue. I changed the PR title to |
Purpose
Linked issue: close #252
A source-backed primary-key index payload uses one immutable ordered source list as its ordinal namespace. After an update retires only part of that list, the current reader requires the payload to equal the complete active source set of its data level. It rejects the still-valid payload and degrades every surviving indexed file to an ordinary scan. Query results remain correct; this PR only avoids that performance fallback.
The same optimization is tracked for Java and Python in apache/paimon#9458, with the aligned change in apache/paimon#9460.
Key code and data-flow changes
source_meta.DataLevel().PrimaryKeyIndexSourcePolicy::ShouldRead, usingdata level + file name + row countas the scan-side source identity.IndexedSplit.This restores index reuse for surviving compact files without introducing a new writer lifecycle or allowing an uncovered file to depend on stale index metadata.
Error and compatibility boundaries
Tests
PkSortedBucketIndexStateTest.*:PrimaryKeySortedIndexScanTest.*— 37/37 passed.core_test— 1,747 passed, 100 skipped, 0 failed (1,847 total).DataLevelbinding regression set — 3/3 passed: cross-level source fallback, retired-source ordinal preservation, and wrong-level payload rejection.clang-formatdry-run andgit diff --checkpass.API and Format
No public include API, storage format, or index protocol changes. The change only broadens safe read-side reuse of one existing source-backed payload per level.
Documentation
Updated the primary-key global-index user guide to describe immutable source groups, partial active coverage, the one-group-per-level boundary, declared-level validation, and fallback behavior.
Generative AI tooling
Generated-by: OpenAI Codex (GPT-5)