mirror of
https://github.com/typesense/typesense.git
synced 2025-05-22 14:55:26 +08:00
store posting_list iterators with facet_index initalization
This commit is contained in:
parent
ce4b8e3e2c
commit
dc689fe362
@ -82,14 +82,16 @@ private:
|
||||
std::list<facet_count_t> counts;
|
||||
posting_list_t* seq_id_hashes = nullptr;
|
||||
spp::sparse_hash_map<uint32_t, int64_t> fhash_to_int64_map;
|
||||
posting_list_t::iterator_t facet_index_it;
|
||||
|
||||
bool has_value_index = true;
|
||||
bool has_hash_index = true;
|
||||
|
||||
facet_doc_ids_list_t() {
|
||||
facet_doc_ids_list_t() :
|
||||
seq_id_hashes(new posting_list_t(256)),
|
||||
facet_index_it(seq_id_hashes->new_iterator()) {
|
||||
fvalue_seq_ids.clear();
|
||||
counts.clear();
|
||||
seq_id_hashes = new posting_list_t(256);
|
||||
}
|
||||
|
||||
facet_doc_ids_list_t(const facet_doc_ids_list_t& other) = delete;
|
||||
@ -152,6 +154,8 @@ public:
|
||||
|
||||
posting_list_t* get_facet_hash_index(const std::string& field_name);
|
||||
|
||||
posting_list_t::iterator_t* get_facet_index_it(const std::string& field_name);
|
||||
|
||||
//get fhash=>int64 map for stats
|
||||
const spp::sparse_hash_map<uint32_t, int64_t>& get_fhash_int64_map(const std::string& field_name);
|
||||
};
|
@ -344,6 +344,14 @@ posting_list_t* facet_index_t::get_facet_hash_index(const std::string &field_nam
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
posting_list_t::iterator_t* facet_index_t::get_facet_index_it(const std::string& field_name) {
|
||||
auto facet_index_it = facet_field_map.find(field_name);
|
||||
if(facet_index_it != facet_field_map.end()) {
|
||||
return &facet_index_it->second.facet_index_it;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const spp::sparse_hash_map<uint32_t , int64_t >& facet_index_t::get_fhash_int64_map(const std::string& field_name) {
|
||||
const auto facet_field_map_it = facet_field_map.find(field_name);
|
||||
if(facet_field_map_it == facet_field_map.end()) {
|
||||
|
@ -5894,23 +5894,24 @@ uint64_t Index::get_distinct_id(const std::vector<std::string>& group_by_fields,
|
||||
continue;
|
||||
}
|
||||
|
||||
posting_list_t* facet_hash_index = facet_index_v4->get_facet_hash_index(field_name);
|
||||
std::vector<uint32_t> facet_hashes;
|
||||
posting_list_t::iterator_t facet_index_it = facet_hash_index->new_iterator();
|
||||
facet_index_it.skip_to(seq_id);
|
||||
posting_list_t::iterator_t* facet_index_it = facet_index_v4->get_facet_index_it(field_name);
|
||||
if(facet_index_it) {
|
||||
facet_index_it->skip_to(seq_id);
|
||||
|
||||
if(facet_index_it.valid() && facet_index_it.id() == seq_id) {
|
||||
posting_list_t::get_offsets(facet_index_it, facet_hashes);
|
||||
if (facet_index_it->valid() && facet_index_it->id() == seq_id) {
|
||||
posting_list_t::get_offsets(*facet_index_it, facet_hashes);
|
||||
|
||||
if(search_schema.at(field_name).is_array()) {
|
||||
//LOG(INFO) << "combining hashes for facet array ";
|
||||
for(size_t i = 0; i < facet_hashes.size(); i++) {
|
||||
distinct_id = StringUtils::hash_combine(distinct_id, facet_hashes[i]);
|
||||
if (search_schema.at(field_name).is_array()) {
|
||||
//LOG(INFO) << "combining hashes for facet array ";
|
||||
for (size_t i = 0; i < facet_hashes.size(); i++) {
|
||||
distinct_id = StringUtils::hash_combine(distinct_id, facet_hashes[i]);
|
||||
}
|
||||
} else {
|
||||
const auto &facet_hash = facet_hashes[0];
|
||||
//LOG(INFO) << "combining hashes for facet ";
|
||||
distinct_id = StringUtils::hash_combine(distinct_id, facet_hash);
|
||||
}
|
||||
} else {
|
||||
const auto& facet_hash = facet_hashes[0];
|
||||
//LOG(INFO) << "combining hashes for facet ";
|
||||
distinct_id = StringUtils::hash_combine(distinct_id, facet_hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user