Skip to content

[fix](variant) Skip full footer scan when constructing VariantStatsCaculator#62819

Open
csun5285 wants to merge 1 commit intoapache:masterfrom
csun5285:fix/variant-stats-calculator-init
Open

[fix](variant) Skip full footer scan when constructing VariantStatsCaculator#62819
csun5285 wants to merge 1 commit intoapache:masterfrom
csun5285:fix/variant-stats-calculator-init

Conversation

@csun5285
Copy link
Copy Markdown
Contributor

@csun5285 csun5285 commented Apr 24, 2026

Problem

In vertical compaction, SegmentWriter::init() is called multiple times against the same writer (key columns first, then each value-column group). The footer accumulates across calls, so every additional init() re-scans an ever-larger footer — including entries from prior init()s that the current column_ids cannot address.

Before After
Single construction O(footer accumulated size) O(this init's column_ids size)
N vertical-compaction init() calls O(N²) O(N)

Fix

Snapshot _footer.columns_size() before _create_writers appends new entries and pass it to VariantStatsCaculator as footer_column_offset. The constructor only walks [offset, end) — its own slice.

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

…culator

SegmentWriter::init() can run multiple times against the same writer
(vertical compaction's key columns + per value-column-group calls), and
the footer accumulates entries across calls. The calculator was scanning
the whole footer on every construction, so each additional init() walked
an ever-larger footer that included entries it cannot address via the
init's own `column_ids`.

Snapshot the footer size before _create_writers appends new entries and
pass it to VariantStatsCaculator as `footer_column_offset`, so the
constructor only scans its own slice. Per-init() construction cost goes
from O(footer accumulated size) to O(this init's column_ids size); the
total cost across N vertical-compaction init() calls drops from O(N^2)
to O(N).

All existing behavior is preserved (including the defensive
Status::NotFound on missing footer entries). One new unit test covers
the offset case.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hello-stephen
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@csun5285
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (4/4) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.43% (26782/37494)
Line Coverage 53.79% (279652/519859)
Region Coverage 47.07% (214603/455963)
Branch Coverage 50.43% (97260/192877)

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