This is an automated email from the ASF dual-hosted git repository. colinlee pushed a commit to branch colin_fix_writer in repository https://gitbox.apache.org/repos/asf/tsfile.git
commit d12ff2eb59ee4f12db617f2234dd1a6cc3efc2df Author: ColinLee <[email protected]> AuthorDate: Thu Mar 20 12:07:43 2025 +0800 add memory_threshold. --- cpp/src/cwrapper/tsfile_cwrapper.h | 4 ++-- cpp/src/writer/tsfile_table_writer.h | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cpp/src/cwrapper/tsfile_cwrapper.h b/cpp/src/cwrapper/tsfile_cwrapper.h index b152782b..d43e5dce 100644 --- a/cpp/src/cwrapper/tsfile_cwrapper.h +++ b/cpp/src/cwrapper/tsfile_cwrapper.h @@ -155,8 +155,8 @@ TsFileWriter tsfile_writer_new(WriteFile file, TableSchema* schema, * @param file Target file where the table data will be written. * @param schema Table schema definition. * - Ownership: Should be free it by Caller. - * @param memory_threshold used to limit the memory size - * of objects. If set to 0, no memory limit is enforced. + * @param memory_threshold When the size of written data exceeds + * this value, the data will be automatically flushed to the disk. * @param err_code [out] E_OK(0), or check error code in errno_define_c.h. * * @return TsFileWriter Valid handle on success, NULL on failure. diff --git a/cpp/src/writer/tsfile_table_writer.h b/cpp/src/writer/tsfile_table_writer.h index 2b37395f..72d2833e 100644 --- a/cpp/src/writer/tsfile_table_writer.h +++ b/cpp/src/writer/tsfile_table_writer.h @@ -45,12 +45,13 @@ class TsFileTableWriter { * not be null. * @param table_schema Used to construct table structures. Defines the * schema of the table being written. - * @param memory_threshold Optional parameter used to limit the memory size - * of objects. If set to 0, no memory limit is enforced. + * @param memory_threshold Optional parameter. When the size of written + * data exceeds this value, the data will be automatically flushed to the + * disk. Default value is 128MB. */ template <typename T> explicit TsFileTableWriter(storage::WriteFile* writer_file, T* table_schema, - uint64_t memory_threshold = 0) { + uint64_t memory_threshold = 128 * 1024 * 1024) { static_assert(!std::is_same<T, std::nullptr_t>::value, "table_schema cannot be nullptr"); tsfile_writer_ = std::make_shared<TsFileWriter>(); @@ -62,6 +63,7 @@ class TsFileTableWriter { auto table_schema_ptr = std::make_shared<TableSchema>(*table_schema); tsfile_writer_->register_table(table_schema_ptr); exclusive_table_name_ = table_schema->get_table_name(); + common::g_config_value_.chunk_group_size_threshold_ = memory_threshold; } ~TsFileTableWriter();
