Skip to content

feat(spill): support to create ExternalSortBuffer in WriteBuffer#265

Merged
lxy-9602 merged 7 commits intoalibaba:mainfrom
zjw1111:feature/spill-to-disk
May 9, 2026
Merged

feat(spill): support to create ExternalSortBuffer in WriteBuffer#265
lxy-9602 merged 7 commits intoalibaba:mainfrom
zjw1111:feature/spill-to-disk

Conversation

@zjw1111
Copy link
Copy Markdown
Collaborator

@zjw1111 zjw1111 commented May 8, 2026

Purpose

Linked issue: #149

Decide whether to create a spill-capable ExternalSortBuffer in WriteBuffer based on the write-buffer-spillable option and IOManager.

Tests

KeyValueFileStoreWriteTest.TestSpillSimple

API and Format

No storage format or protocol changes

Documentation

No documentation changes needed.

Generative AI tooling

Generated-by: Aone Copilot(Claude 4.6) and Github Copilot(GPT-5.4)

…spill-to-disk

- Refactor MergeTreeWriter constructor to factory method Create() that returns
  Result<shared_ptr<MergeTreeWriter>>, enabling fallible initialization
- Refactor WriteBuffer constructor to factory method Create() that returns
  Result<unique_ptr<WriteBuffer>>
- Add IOManager parameter to support ExternalSortBuffer when spillable is enabled
- Add FlushMemory() method to MergeTreeWriter and WriteBuffer for spill support
- Change Write() return type from Status to Result<bool> to signal buffer quota
- Rename internal Flush() to FlushWriteBuffer() for clarity
- Add user_defined_seq_comparator parameter to WriteBuffer::Create
- Fix typo: TestWithPosistion -> TestWithPosition
- Update all related test cases to use new factory methods
Copilot AI review requested due to automatic review settings May 8, 2026 05:26
@zjw1111 zjw1111 changed the title feat(mergetree): refactor WriteBuffer and MergeTreeWriter to support spill-to-disk feat(mergetree): support to create ExternalSortBuffer in WriteBuffer May 8, 2026
Copy link
Copy Markdown

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

Note

Copilot was unable to run its full agentic suite in this review.

Refactors WriteBuffer and MergeTreeWriter to enable spill-to-disk support by switching to fallible factory initialization, adding IOManager plumbing, and introducing a memory-flush API used by a new writer memory manager.

Changes:

  • Replaced WriteBuffer / MergeTreeWriter constructors with Create() factory methods and updated call sites/tests accordingly.
  • Added spill-related APIs (FlushMemory(), Write(): Result<bool>) and routed buffering through SortBuffer (in-memory vs external).
  • Introduced WriterMemoryManager integration in AbstractFileStoreWrite and added a spill behavior test using .channel files.

Reviewed changes

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

Show a summary per file
File Description
src/paimon/testing/utils/test_helper.h Adds helper to count spill “channel” files in tests.
src/paimon/core/operation/key_value_file_store_write_test.cpp Adds spill-to-disk behavior test and updates includes.
src/paimon/core/operation/key_value_file_store_write.cpp Switches writer creation to MergeTreeWriter::Create(...) and passes io_manager_.
src/paimon/core/operation/abstract_file_store_write.h Adds WriterMemoryManager member wiring.
src/paimon/core/operation/abstract_file_store_write.cpp Registers/unregisters writers and refreshes memory tracking around writes/commits.
src/paimon/core/mergetree/write_buffer_test.cpp Updates tests to use WriteBuffer::Create() and Result<bool> write API.
src/paimon/core/mergetree/write_buffer.h Introduces factory Create(), FlushMemory(), and new Write() return type.
src/paimon/core/mergetree/write_buffer.cpp Implements spillable SortBuffer selection and forwards Write/FlushMemory.
src/paimon/core/mergetree/merge_tree_writer_test.cpp Migrates to MergeTreeWriter::Create() and parameterizes tests for IOManager presence.
src/paimon/core/mergetree/merge_tree_writer.h Adds Create(), FlushMemory(), and renames internal flush to FlushWriteBuffer().
src/paimon/core/mergetree/merge_tree_writer.cpp Implements factory construction, spill flush flow, and new write/flush behavior.
src/paimon/core/mergetree/lookup_levels_test.cpp Updates to MergeTreeWriter::Create() and fixes test typo name.
src/paimon/core/mergetree/lookup/remote_lookup_file_manager_test.cpp Updates to MergeTreeWriter::Create().
src/paimon/core/mergetree/compact/lookup_merge_tree_compact_rewriter_test.cpp Updates to MergeTreeWriter::Create().

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

Comment thread src/paimon/core/mergetree/write_buffer_test.cpp
Comment thread src/paimon/core/mergetree/write_buffer.cpp
Comment thread src/paimon/testing/utils/test_helper.h Outdated
Comment thread src/paimon/core/mergetree/merge_tree_writer_test.cpp
Comment thread src/paimon/core/mergetree/merge_tree_writer_test.cpp Outdated
Comment thread src/paimon/core/mergetree/merge_tree_writer.cpp
@zjw1111 zjw1111 changed the title feat(mergetree): support to create ExternalSortBuffer in WriteBuffer feat(spill): support to create ExternalSortBuffer in WriteBuffer May 8, 2026
Comment thread src/paimon/core/mergetree/write_buffer.h
Comment thread src/paimon/core/operation/abstract_file_store_write.h
Comment thread src/paimon/testing/utils/test_helper.h Outdated
Comment thread src/paimon/core/operation/key_value_file_store_write_test.cpp
Comment thread src/paimon/core/mergetree/merge_tree_writer_test.cpp
zjw1111 and others added 3 commits May 8, 2026 16:43
@lucasfang
Copy link
Copy Markdown
Collaborator

+1

Copy link
Copy Markdown
Collaborator

@lxy-9602 lxy-9602 left a comment

Choose a reason for hiding this comment

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

+1

@lxy-9602 lxy-9602 merged commit 16950cc into alibaba:main May 9, 2026
9 checks passed
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.

4 participants