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
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Parameterize compaction of store during collection drop.
Kishore Nallanaf43190b826b
diff --git a/include/collection_manager.h b/include/collection_manager.hindex 1ef88ee9..86423f8f 100644--- a/include/collection_manager.h+++ b/include/collection_manager.h@@ -165,7 +165,9 @@ public:nlohmann::json get_collection_summaries() const;- Option<nlohmann::json> drop_collection(const std::string& collection_name, const bool remove_from_store = true);+ Option<nlohmann::json> drop_collection(const std::string& collection_name,+ const bool remove_from_store = true,+ const bool compact_store = true);uint32_t get_next_collection_id() const;diff --git a/src/collection_manager.cpp b/src/collection_manager.cppindex 7b8510cf..971072eb 100644--- a/src/collection_manager.cpp+++ b/src/collection_manager.cpp@@ -486,7 +486,9 @@ std::vector<std::string> CollectionManager::get_collection_names() const {return collection_vec;}-Option<nlohmann::json> CollectionManager::drop_collection(const std::string& collection_name, const bool remove_from_store) {+Option<nlohmann::json> CollectionManager::drop_collection(const std::string& collection_name,+ const bool remove_from_store,+ const bool compact_store) {std::shared_lock s_lock(mutex);auto collection = get_collection_unsafe(collection_name);@@ -503,8 +505,11 @@ Option<nlohmann::json> CollectionManager::drop_collection(const std::string& colconst std::string& del_key_prefix = std::to_string(collection->get_collection_id()) + "_";const std::string& del_end_prefix = std::to_string(collection->get_collection_id()) + "`";store->delete_range(del_key_prefix, del_end_prefix);- store->flush();- store->compact_range(del_key_prefix, del_end_prefix);++ if(compact_store) {+ store->flush();+ store->compact_range(del_key_prefix, del_end_prefix);+ }// delete overridesconst std::string& del_override_prefix =diff --git a/src/core_api.cpp b/src/core_api.cppindex 62b151fe..75799f18 100644--- a/src/core_api.cpp+++ b/src/core_api.cpp@@ -239,9 +239,14 @@ bool patch_update_collection(const std::shared_ptr<http_req>& req, const std::sh}bool del_drop_collection(const std::shared_ptr<http_req>& req, const std::shared_ptr<http_res>& res) {- std::string doc_id = req->params["id"];+ bool compact_store = false;++ if(req->params.count("compact_store") != 0) {+ compact_store = (req->params["compact_store"] == "true");+ }+CollectionManager & collectionManager = CollectionManager::get_instance();- Option<nlohmann::json> drop_op = collectionManager.drop_collection(req->params["collection"], true);+ Option<nlohmann::json> drop_op = collectionManager.drop_collection(req->params["collection"], true, compact_store);if(!drop_op.ok()) {res->set(drop_op.code(), drop_op.error());