Skip to content

Commit a6a3af4

Browse files
committed
feat: add spill-to-disk write buffer path
1 parent e7ffea3 commit a6a3af4

43 files changed

Lines changed: 3413 additions & 569 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
build
1717
build-release
1818
build-debug
19+
build-test
1920
output
2021

2122
# IDE settings

include/paimon/defs.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,23 @@ struct PAIMON_EXPORT Options {
178178
/// on-disk file. The default value is 256 mb
179179
static const char WRITE_BUFFER_SIZE[];
180180

181+
/// "write-buffer-spillable" - Whether the write buffer can be spillable. Default value is true.
182+
static const char WRITE_BUFFER_SPILLABLE[];
183+
184+
/// "write-buffer-spill.max-disk-size" - The max disk to use for write buffer spill. This only
185+
/// work when the write buffer spill is enabled. Default value is unlimited.
186+
static const char WRITE_BUFFER_SPILL_MAX_DISK_SIZE[];
187+
188+
/// "local-sort.max-num-file-handles" - The maximal fan-in for external merge sort. It limits
189+
/// the number of file handles. If it is too small, may cause intermediate merging. But if it is
190+
/// too large, it will cause too many files opened at the same time, consume memory and lead to
191+
/// random reading. Default value is 128.
192+
static const char LOCAL_SORT_MAX_NUM_FILE_HANDLES[];
193+
194+
/// "spill-compression" - Compression for spill.
195+
/// Default value is zstd.
196+
static const char SPILL_COMPRESSION[];
197+
181198
/// "snapshot.num-retained.min" - The minimum number of completed snapshots to retain. Should be
182199
/// greater than or equal to 1. Default value is 10
183200
static const char SNAPSHOT_NUM_RETAINED_MIN[];

src/paimon/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ set(PAIMON_CORE_SRCS
213213
core/io/key_value_data_file_record_reader.cpp
214214
core/io/key_value_data_file_writer.cpp
215215
core/io/key_value_in_memory_record_reader.cpp
216+
core/io/merged_key_value_record_reader.cpp
216217
core/io/key_value_meta_projection_consumer.cpp
217218
core/io/key_value_projection_consumer.cpp
218219
core/io/key_value_projection_reader.cpp
@@ -241,12 +242,16 @@ set(PAIMON_CORE_SRCS
241242
core/mergetree/compact/merge_tree_compact_rewriter.cpp
242243
core/mergetree/compact/merge_tree_compact_task.cpp
243244
core/mergetree/compact/partial_update_merge_function.cpp
245+
core/mergetree/compact/raw_sort_merge_reader_with_min_heap.cpp
244246
core/mergetree/compact/sort_merge_reader_with_loser_tree.cpp
245247
core/mergetree/compact/sort_merge_reader_with_min_heap.cpp
246248
core/mergetree/compact/lookup_merge_tree_compact_rewriter.cpp
247249
core/mergetree/compact/changelog_merge_tree_rewriter.cpp
248250
core/mergetree/merge_tree_writer.cpp
251+
core/mergetree/binary_in_memory_sort_buffer.cpp
252+
core/mergetree/binary_external_sort_buffer.cpp
249253
core/mergetree/write_buffer.cpp
254+
core/mergetree/writer_memory_manager.cpp
250255
core/mergetree/levels.cpp
251256
core/mergetree/lookup_file.cpp
252257
core/mergetree/lookup_levels.cpp
@@ -564,6 +569,7 @@ if(PAIMON_BUILD_TESTS)
564569
core/io/key_value_data_file_record_reader_test.cpp
565570
core/io/key_value_projection_reader_test.cpp
566571
core/io/key_value_in_memory_record_reader_test.cpp
572+
core/io/merged_key_value_record_reader_test.cpp
567573
core/io/complete_row_tracking_fields_reader_test.cpp
568574
core/io/data_file_meta_test.cpp
569575
core/io/file_index_evaluator_test.cpp
@@ -624,6 +630,7 @@ if(PAIMON_BUILD_TESTS)
624630
core/mergetree/sorted_run_test.cpp
625631
core/mergetree/spill_channel_manager_test.cpp
626632
core/mergetree/spill_reader_writer_test.cpp
633+
core/mergetree/writer_memory_manager_test.cpp
627634
core/migrate/file_meta_utils_test.cpp
628635
core/operation/metrics/compaction_metrics_test.cpp
629636
core/operation/data_evolution_file_store_scan_test.cpp

src/paimon/common/defs.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ const char Options::SCAN_MODE[] = "scan.mode";
5050
const char Options::READ_BATCH_SIZE[] = "read.batch-size";
5151
const char Options::WRITE_BATCH_SIZE[] = "write.batch-size";
5252
const char Options::WRITE_BUFFER_SIZE[] = "write-buffer-size";
53+
const char Options::WRITE_BUFFER_SPILLABLE[] = "write-buffer-spillable";
54+
const char Options::WRITE_BUFFER_SPILL_MAX_DISK_SIZE[] = "write-buffer-spill.max-disk-size";
55+
const char Options::LOCAL_SORT_MAX_NUM_FILE_HANDLES[] = "local-sort.max-num-file-handles";
56+
const char Options::SPILL_COMPRESSION[] = "spill-compression";
5357
const char Options::SNAPSHOT_NUM_RETAINED_MIN[] = "snapshot.num-retained.min";
5458
const char Options::SNAPSHOT_NUM_RETAINED_MAX[] = "snapshot.num-retained.max";
5559
const char Options::SNAPSHOT_TIME_RETAINED[] = "snapshot.time-retained";

src/paimon/common/utils/string_utils_test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ TEST_F(StringUtilsTest, TestSplit) {
326326
StringUtils::Split("key1=value1//key3=value3", std::string("/"), std::string("="));
327327
ASSERT_EQ(expect, result);
328328
}
329+
{
330+
std::vector<std::vector<std::string>> expect = {};
331+
std::vector<std::vector<std::string>> result =
332+
StringUtils::Split("", std::string("/"), std::string("="));
333+
ASSERT_EQ(expect, result);
334+
}
329335
}
330336

331337
TEST_F(StringUtilsTest, TestStringToValueSimple) {

0 commit comments

Comments
 (0)