#pragma once #include #include #include #include #include #include #include class Collection { private: Store* store; // Integer ID used internally for bitmaps - not exposed to the client uint32_t seq_id; art_tree t; spp::sparse_hash_map doc_scores; uint32_t next_seq_id(); const std::string SEQ_ID_PREFIX = "SQ_"; const std::string ID_PREFIX = "ID_"; std::string get_seq_id_key(uint32_t seq_id); std::string get_id_key(std::string id); static inline std::vector next_suggestion(const std::vector> &token_leaves, long long int n); void log_leaves(const int max_cost, const std::string &token, const std::vector &leaves) const; void search_candidates(std::vector> & token_leaves, Topster<100> & topster, size_t & total_results, const size_t & max_results); public: Collection() = delete; Collection(std::string state_dir_path); ~Collection(); std::string add(std::string json_str); std::vector search(std::string query, const int num_typos, const size_t num_results); void remove(std::string id); void score_results(Topster<100> &topster, const std::vector &query_suggestion, const uint32_t *result_ids, size_t result_size) const; enum {MAX_SEARCH_TOKENS = 20}; enum {MAX_RESULTS = 100}; };