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

refactoring lookup map

krunal96f9304ce144
diff --git a/include/facet_index.h b/include/facet_index.h
index 4293f214..651b15a9 100644
--- a/include/facet_index.h
+++ b/include/facet_index.h
@@ -109,7 +109,7 @@ private:
// field -> facet_index
std::unordered_map<std::string, facet_doc_ids_list_t> facet_field_map;
- std::unordered_map<uint32_t, int64_t> index_to_int64_map;
+ spp::sparse_hash_map<uint32_t, int64_t> fhash_to_int64_map;
// auto incrementing ID that is assigned to each unique facet value string
uint32_t next_facet_id = 0;
diff --git a/src/facet_index.cpp b/src/facet_index.cpp
index 2a4fc993..37508c6d 100644
--- a/src/facet_index.cpp
+++ b/src/facet_index.cpp
@@ -40,7 +40,7 @@ void facet_index_t::insert(const std::string& field_name,std::unordered_map<face
if(!is_string_field) {
int64_t val = std::stoll(fvalue.facet_value);
- index_to_int64_map[facet_id] = val;
+ fhash_to_int64_map[facet_id] = val;
}
}
@@ -341,9 +341,9 @@ posting_list_t* facet_index_t::get_facet_hash_index(const std::string &field_nam
}
int64_t facet_index_t::get_facet_val(uint32_t index) {
- auto it = index_to_int64_map.find(index);
+ auto it = fhash_to_int64_map.find(index);
- if(it != index_to_int64_map.end()) {
+ if(it != fhash_to_int64_map.end()) {
return it->second;
}