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

Temporarily disable memory threshold check.

kishorencd3d25768a0de
diff --git a/include/collection_manager.h b/include/collection_manager.h
index dc20f594..7a5be35c 100644
--- a/include/collection_manager.h
+++ b/include/collection_manager.h
@@ -63,7 +63,7 @@ public:
Option<bool> load(const size_t init_batch_size=1000);
- // frees in-memory data structures when server is shutdown - helps us run a memory leak detecter properly
+ // frees in-memory data structures when server is shutdown - helps us run a memory leak detector properly
void dispose();
Collection* init_collection(const nlohmann::json & collection_meta, const uint32_t collection_next_seq_id);
@@ -84,7 +84,7 @@ public:
std::vector<Collection*> get_collections();
- Option<bool> drop_collection(std::string collection_name, const bool remove_from_store = true);
+ Option<bool> drop_collection(const std::string& collection_name, const bool remove_from_store = true);
uint32_t get_next_collection_id();
diff --git a/src/collection.cpp b/src/collection.cpp
index 6767e9f8..5d4a9218 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -160,9 +160,9 @@ Option<nlohmann::json> Collection::add(const std::string & json_str) {
return Option<nlohmann::json>(doc_seq_id_op.code(), doc_seq_id_op.error());
}
- if(is_exceeding_memory_threshold()) {
+ /*if(is_exceeding_memory_threshold()) {
return Option<nlohmann::json>(403, "Max memory ratio exceeded.");
- }
+ }*/
const uint32_t seq_id = doc_seq_id_op.get();
const std::string seq_id_str = std::to_string(seq_id);
@@ -220,6 +220,7 @@ nlohmann::json Collection::add_many(std::vector<std::string>& json_lines) {
record.index_failure(doc_seq_id_op.code(), doc_seq_id_op.error());
}
+ /*
// check for memory threshold before allowing subsequent batches
if(is_exceeding_memory_threshold()) {
exceeds_memory_limit = true;
@@ -233,6 +234,7 @@ nlohmann::json Collection::add_many(std::vector<std::string>& json_lines) {
json_lines[i] = index_res.dump();
record.index_failure(500, "Max memory ratio exceeded.");
}
+ */
iter_batch[seq_id % this->get_num_memory_shards()].emplace_back(record);
diff --git a/src/collection_manager.cpp b/src/collection_manager.cpp
index d102ffbe..ca73391d 100644
--- a/src/collection_manager.cpp
+++ b/src/collection_manager.cpp
@@ -191,6 +191,7 @@ Option<bool> CollectionManager::load(const size_t init_batch_size) {
}
add_to_collections(collection);
+ LOG(INFO) << "Loaded " << num_docs_read << " documents into collection " << collection->get_name();
}
std::string symlink_prefix_key = std::string(SYMLINK_PREFIX) + "_";
@@ -343,7 +344,7 @@ std::vector<Collection*> CollectionManager::get_collections() {
return collection_vec;
}
-Option<bool> CollectionManager::drop_collection(std::string collection_name, const bool remove_from_store) {
+Option<bool> CollectionManager::drop_collection(const std::string& collection_name, const bool remove_from_store) {
Collection* collection = get_collection(collection_name);
if(collection == nullptr) {
return Option<bool>(404, "No collection with name `" + collection_name + "` found.");
@@ -352,8 +353,7 @@ Option<bool> CollectionManager::drop_collection(std::string collection_name, con
if(remove_from_store) {
const std::string &collection_id_str = std::to_string(collection->get_collection_id());
- // Note: The following order of dropping documents first before dropping collection meta is important for
- // replication to work properly!
+ // Note: The order of dropping documents first before dropping collection meta is important for replication
rocksdb::Iterator* iter = store->scan(collection_id_str);
while(iter->Valid() && iter->key().starts_with(collection_id_str)) {
store->remove(iter->key().ToString());