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

Add some comments to improve readability.

kishorenc8900347eed6e
diff --git a/include/field.h b/include/field.h
index e88b7c16..2d145ea1 100644
--- a/include/field.h
+++ b/include/field.h
@@ -134,6 +134,7 @@ struct facet_value {
spp::sparse_hash_map<std::string, uint32_t> value_index;
spp::sparse_hash_map<uint32_t, std::string> index_value;
+ // doc_id => facet_ids mapping
spp::sparse_hash_map<uint32_t, std::vector<uint32_t>> doc_values;
uint32_t get_value_index(const std::string & value) {
diff --git a/src/index.cpp b/src/index.cpp
index 89e8eb54..ce37a480 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -523,7 +523,7 @@ void Index::do_facets(std::vector<facet> & facets, const uint32_t* result_ids, s
for(size_t i = 0; i < results_size; i++) {
uint32_t doc_seq_id = result_ids[i];
if(fvalue.doc_values.count(doc_seq_id) != 0) {
- // for every result document, get the values associated and increment counter
+ // for every result document, get the facet values and increment counter
const std::vector<uint32_t> & value_indices = fvalue.doc_values.at(doc_seq_id);
for(size_t j = 0; j < value_indices.size(); j++) {
const std::string & facet_value = fvalue.index_value.at(value_indices.at(j));
diff --git a/src/sorted_array.cpp b/src/sorted_array.cpp
index bd7d916c..228f6ba8 100644
--- a/src/sorted_array.cpp
+++ b/src/sorted_array.cpp
@@ -125,6 +125,7 @@ void sorted_array::indexOf(const uint32_t *values, const size_t values_len, uint
uint32_t low_index, high_index;
uint32_t actual_value = 0;
+ // identify the upper and lower bounds of the search space
int head = -1;
do {
head++;
@@ -145,6 +146,7 @@ void sorted_array::indexOf(const uint32_t *values, const size_t values_len, uint
indices[j] = length;
}
+ // recursively search within the bounds for all values
binary_search_indices(values, head, tail, low_index, high_index, base, bits, indices);
}