From 2ae37626bbed7b50069a900f3ab4e890bfbf1e8a Mon Sep 17 00:00:00 2001 From: qiye Date: Sat, 12 Oct 2024 17:13:55 +0800 Subject: [PATCH] [opt](index compaction)Use RAM dir to create tmp index_writer (#41371) (#41705) ## Proposed changes bp #41371 --- .../rowset/segment_v2/inverted_index_compaction.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/be/src/olap/rowset/segment_v2/inverted_index_compaction.cpp b/be/src/olap/rowset/segment_v2/inverted_index_compaction.cpp index 40a1d2218f..51aeab0cb4 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_compaction.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_compaction.cpp @@ -39,8 +39,9 @@ Status compact_column(int64_t index_id, std::vector& "debug point: index compaction error"); } }) - - lucene::store::Directory* dir = DorisFSDirectoryFactory::getDirectory(fs, tmp_path.c_str()); + bool can_use_ram_dir = true; + lucene::store::Directory* dir = + DorisFSDirectoryFactory::getDirectory(fs, tmp_path.c_str(), can_use_ram_dir); lucene::analysis::SimpleAnalyzer analyzer; auto* index_writer = _CLNEW lucene::index::IndexWriter(dir, &analyzer, true /* create */, true /* closeDirOnShutdown */); @@ -69,8 +70,10 @@ Status compact_column(int64_t index_id, std::vector& } } - // delete temporary segment_path - static_cast(fs->delete_directory(tmp_path.c_str())); + // delete temporary segment_path, only when inverted_index_ram_dir_enable is false + if (!config::inverted_index_ram_dir_enable) { + static_cast(fs->delete_directory(tmp_path.c_str())); + } return Status::OK(); } } // namespace doris::segment_v2