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 concurrency of ja tokenizer.

Kishore Nallan397727fdbc93
diff --git a/include/japanese_localizer.h b/include/japanese_localizer.h
index 42f38571..a8f2bd76 100644
--- a/include/japanese_localizer.h
+++ b/include/japanese_localizer.h
@@ -1,6 +1,7 @@
#pragma once
#include <string>
+#include <mutex>
class JapaneseLocalizer {
private:
@@ -10,6 +11,8 @@ private:
static void write_data_file(const std::string& base64_data, const std::string& file_name);
+ std::mutex m;
+
public:
static JapaneseLocalizer & get_instance() {
diff --git a/src/japanese_localizer.cpp b/src/japanese_localizer.cpp
index 5403e91e..c0ad4b1f 100644
--- a/src/japanese_localizer.cpp
+++ b/src/japanese_localizer.cpp
@@ -43,6 +43,7 @@ bool JapaneseLocalizer::init() {
}
char* JapaneseLocalizer::normalize(const std::string& text) {
+ std::unique_lock lk(m);
return kakasi_do((char *)text.c_str());
}