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

Handle v0.21 and below import serialization.

Kishore Nallan952b83f3a825
diff --git a/include/http_data.h b/include/http_data.h
index 7190c8f1..c4a748fd 100644
--- a/include/http_data.h
+++ b/include/http_data.h
@@ -293,7 +293,13 @@ struct http_req {
void load_from_json(const std::string& serialized_content) {
nlohmann::json content = nlohmann::json::parse(serialized_content);
route_hash = content["route_hash"];
- body += content["body"];
+
+ if(start_ts == 0) {
+ // Serialized request from an older version (v0.21 and below) which serializes import data differently.
+ body = content["body"];
+ } else {
+ body += content["body"];
+ }
for (nlohmann::json::iterator it = content["params"].begin(); it != content["params"].end(); ++it) {
params.emplace(it.key(), it.value());
diff --git a/src/batched_indexer.cpp b/src/batched_indexer.cpp
index cc78f848..b50a9bb3 100644
--- a/src/batched_indexer.cpp
+++ b/src/batched_indexer.cpp
@@ -74,6 +74,22 @@ void BatchedIndexer::enqueue(const std::shared_ptr<http_req>& req, const std::sh
std::unique_lock lk(mutex);
request_to_chunk.erase(req->start_ts);
+ lk.unlock();
+
+ if(req->start_ts == 0) {
+ // Indicates a serialized request from a version that did not support batching (v0.21 and below).
+ // We can only do serial writes as we cannot reliably distinguish one streaming request from another.
+ // So, wait for `req_res_map` to be empty before proceeding
+ while(true) {
+ lk.lock();
+ if(req_res_map.empty()) {
+ break;
+ }
+ lk.unlock();
+
+ std::this_thread::sleep_for(std::chrono::milliseconds (10));
+ }
+ }
}
if(req->_req != nullptr && req->_req->proceed_req) {