Skip to content

feat(compaction): support compaction for key table in framework#195

Open
lucasfang wants to merge 7 commits intoalibaba:mainfrom
lucasfang:compaction_dev
Open

feat(compaction): support compaction for key table in framework#195
lucasfang wants to merge 7 commits intoalibaba:mainfrom
lucasfang:compaction_dev

Conversation

@lucasfang
Copy link
Collaborator

@lucasfang lucasfang commented Mar 23, 2026

Purpose

  • Add key-table compaction support in framework.
  • Follow up with stability and maintainability fixes, including full-compaction behavior, cancellation wiring, logging improvements, and related refactor/cleanup.

Tests

  • UT

    • MergeTreeCompactManagerTest
      • TestOutputToZeroLevel
      • TestCompactToPenultimateLayer
      • TestNoCompaction
      • TestNormal
      • TestUpgrade
      • TestSmallFiles
      • TestSmallFilesNoCompact
      • TestSmallFilesCrossLevel
      • TestComplex
      • TestSmallInComplex
      • TestIsCompacting
      • TestTriggerFullCompaction
      • TestRejectReentrantFullCompaction
    • MergeTreeCompactRewriterTest
      • TestSimple
      • TestNotDropDelete
      • TestIOException
  • IT

    • KeyValueCompactionInteTest
      • TestKeyValueTableCompactionWithIOException
      • TestKeyValueTableStreamWriteFullCompaction (parameterized by file format)
    • AppendCompactionInteTest
      • TestAppendTableStreamWriteFullCompaction (parameterized by file format)
      • TestAppendTableStreamWriteFullCompactionWithDv (parameterized by file format)
      • TestAppendTableStreamWriteBestEffortCompaction (parameterized by file format)
      • TestAppendTableStreamWriteCompactionWithExternalPath (parameterized by file format)
      • TestAppendTableCompactionWithIOException
    • WriteInteTest
      • TestAppendTableWriteWithAlterTable
      • TestPKTableWriteWithAlterTable

API and Format

  • No external public API behavior change in include directory.
  • No storage format or protocol change.
  • Internal interfaces under src are updated for cancellation propagation (constructor/signature changes in internal classes only).

Documentation

  • No new user-facing feature toggle introduced.
  • No additional documentation required in this PR.

Generative AI tooling

Generated-by: GitHub Copilot (GPT-5.3-Codex)

Copilot AI review requested due to automatic review settings March 23, 2026 01:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds merge-tree compaction support for key-table writes in the C++ framework by wiring a real CompactManager into MergeTreeWriter, introducing new compaction/lookup-related options, and adding unit/integration tests around the new behavior.

Changes:

  • Implement merge-tree compaction orchestration (MergeTreeCompactManager + tasks) and integrate it into KeyValueFileStoreWrite/MergeTreeWriter.
  • Extend compaction configuration via new CoreOptions fields (sorted-run triggers, levels, lookup compact mode/interval, force up-level-0).
  • Add/adjust tests (unit + integration) and update interfaces to propagate Status/Result for compaction-related operations.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/inte/key_value_compaction_inte_test.cpp New integration test exercising key-table compaction under injected IO failures.
test/inte/CMakeLists.txt Registers the new integration test target.
src/paimon/core/options/lookup_strategy_test.cpp Unit tests for LookupStrategy::From behavior and combinations.
src/paimon/core/options/lookup_strategy.h Introduces LookupStrategy helper for deriving need_lookup.
src/paimon/core/options/lookup_compact_mode.h Adds LookupCompactMode enum used by lookup compaction strategy selection.
src/paimon/core/operation/key_value_file_store_write.h Extends writer to accept a comparator suitable for compaction and exposes compaction factory helpers.
src/paimon/core/operation/key_value_file_store_write.cpp Creates Levels, compaction strategy, manager, and rewriter; wires compaction manager into MergeTreeWriter.
src/paimon/core/operation/file_store_write.cpp Builds separate comparators (use_view=true/false) and DV maintainer factory; passes into key-value write path.
src/paimon/core/operation/abstract_file_store_write.cpp Propagates Result from CompactDeletionFile::GetOrCompute() into prepare-commit flow.
src/paimon/core/mergetree/merge_tree_writer_test.cpp Updates tests for new MergeTreeWriter ctor requiring a CompactManager (uses NoopCompactManager).
src/paimon/core/mergetree/merge_tree_writer.h Adds Compact/Sync/CompactNotCompleted implementations and compaction state tracking members.
src/paimon/core/mergetree/merge_tree_writer.cpp Implements compaction wiring: sync results, trigger compaction, track compact before/after, handle deletion files.
src/paimon/core/mergetree/lookup_levels_test.cpp Updates test construction to pass NoopCompactManager into MergeTreeWriter.
src/paimon/core/mergetree/compact/merge_tree_compact_task.h New compaction task for merge-tree compaction (rewrite/upgrade decisions + optional DV deletion file).
src/paimon/core/mergetree/compact/merge_tree_compact_manager_test.cpp New unit tests validating MergeTreeCompactManager level/output behavior and lookup compaction “not completed” semantics.
src/paimon/core/mergetree/compact/merge_tree_compact_manager.h New MergeTreeCompactManager interface/implementation declaration.
src/paimon/core/mergetree/compact/merge_tree_compact_manager.cpp Implements compaction triggering, task submission, applying results to Levels, and metrics reporting.
src/paimon/core/mergetree/compact/interval_partition.h Removes redundant forward declarations (relies on includes).
src/paimon/core/mergetree/compact/file_rewrite_compact_task.h New task for file-rewrite style compaction units.
src/paimon/core/core_options_test.cpp Adds coverage for new compaction/lookup options parsing/defaults and lookup strategy derivation.
src/paimon/core/core_options.h Adds new getters for compaction knobs and lookup strategy/mode/levels.
src/paimon/core/core_options.cpp Parses/stores new options, computes derived defaults, and centralizes NeedLookup() via LookupStrategy.
src/paimon/core/compact/noop_compact_manager.h Updates AddNewFile signature to return Status.
src/paimon/core/compact/compact_manager.h Changes AddNewFile to return Status for error propagation.
src/paimon/core/compact/compact_deletion_file_test.cpp Adapts tests to Result<optional<...>> API and adds tests for lazy generation behavior.
src/paimon/core/compact/compact_deletion_file.h Adds lazy deletion-file generation and changes GetOrCompute() to return Result<optional<...>>.
src/paimon/core/append/bucketed_append_compact_manager.h Updates AddNewFile signature to return Status.
src/paimon/core/append/append_only_writer.cpp Propagates Status from CompactManager::AddNewFile.
src/paimon/common/defs.cpp Adds option key constants for new compaction/lookup configuration options.
src/paimon/CMakeLists.txt Adds new sources and unit tests to the build.
include/paimon/defs.h Documents new compaction/lookup configuration keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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