[core] Optimize field matching in DataEvolutionFileStoreScan.evolutionStats with HashMap - #9045
Closed
leaves12138 wants to merge 1 commit into
Closed
[core] Optimize field matching in DataEvolutionFileStoreScan.evolutionStats with HashMap#9045leaves12138 wants to merge 1 commit into
leaves12138 wants to merge 1 commit into
Conversation
…nStats with HashMap Replace the triple nested linear scan (target field x file fields x stats fields) with per-file fieldId-to-index HashMap lookups, and stop iterating files once every field is resolved. For tables with wide schemas and many row-id groups, this removes O(F^2) comparisons per group from scan planning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Optimize scan planning for data-evolution tables with wide schemas.
On a production table (1027 columns, ~19856 active files in one snapshot forming ~17670 row-id groups),
DataEvolutionFileStoreScan.postFilterManifestEntriesis extremely slow. Each row-id group callsfilterByStats(group)->evolutionStats(), whose field matching is a triple nested linear scan: for every target field it linearly scans the file's field ids, and on a hit linearly scans the stats field ids again. For a group with K files covering F columns this is O(F * K * F) comparisons, repeated per group, single-threaded.Changes
In
evolutionStats:fieldId -> indexHashMap per file for both the file schema and the stats schema, turning each lookup into O(1).schema.fields().get(j).type()per lookup.Behavior is preserved:
-2(field present without stats) and type-mismatch semantics are unchanged, including the blob/vectorexcludedFileFieldIdsfixup.Verification
DataEvolutionFileStoreScanTest: 8/8 passedDataEvolutionTableTest: 42/42 passed