Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

simulate reload on restart test

krunal281b2be00358
diff --git a/include/stopwords_manager.h b/include/stopwords_manager.h
index a8e22965..a2f0ec11 100644
--- a/include/stopwords_manager.h
+++ b/include/stopwords_manager.h
@@ -39,4 +39,6 @@ public:
Option<bool> upsert_stopword(const std::string&, const nlohmann::json&, bool write_to_store=false);
Option<bool> delete_stopword(const std::string&);
+
+ void dispose();
};
\ No newline at end of file
diff --git a/src/stopwords_manager.cpp b/src/stopwords_manager.cpp
index 7a518edc..f24cb8ab 100644
--- a/src/stopwords_manager.cpp
+++ b/src/stopwords_manager.cpp
@@ -88,4 +88,9 @@ Option<bool> StopwordsManager::delete_stopword(const std::string& stopword_name)
stopword_configs.erase(stopword_name);
return Option<bool>(true);
+}
+
+void StopwordsManager::dispose() {
+ std::unique_lock lock(mutex);
+ stopword_configs.clear();
}
\ No newline at end of file
diff --git a/test/stopwords_manager_test.cpp b/test/stopwords_manager_test.cpp
index 7324dade..8653af19 100644
--- a/test/stopwords_manager_test.cpp
+++ b/test/stopwords_manager_test.cpp
@@ -422,13 +422,14 @@ TEST_F(StopwordsManagerTest, ReloadStopwordsOnRestart) {
//dispose collection manager and reload all stopwords
collectionManager.dispose();
+ stopwordsManager.dispose();
delete store;
stopword_config.clear();
std::string state_dir_path = "/tmp/typesense_test/stopwords_manager";
- system(("rm -rf "+state_dir_path+" && mkdir -p "+state_dir_path).c_str());
store = new Store(state_dir_path);
+ stopwordsManager.init(store);
collectionManager.init(store, 1.0, "auth_key", quit);
collectionManager.load(8, 1000);