ModErn Text Analysis
META Enumerates Textual Applications
cached_index.h
Go to the documentation of this file.
1 
10 #ifndef META_CACHED_INDEX_H_
11 #define META_CACHED_INDEX_H_
12 
13 #include <memory>
14 
15 namespace cpptoml
16 {
17 class table;
18 }
19 
20 namespace meta
21 {
22 namespace index
23 {
24 
29 template <class Index, template <class, class> class Cache>
30 class cached_index : public Index
31 {
32  public:
34  using Index::Index;
35 
46  template <class... Args>
47  cached_index(cpptoml::table& config, Args&&... args);
48 
49  using primary_key_type = typename Index::primary_key_type;
50  using secondary_key_type = typename Index::secondary_key_type;
51  using postings_data_type = typename Index::postings_data_type;
52 
61  virtual std::shared_ptr<postings_data_type>
62  search_primary(primary_key_type p_id) const override;
63 
68  void clear_cache();
69 
70  private:
74  mutable Cache<primary_key_type, std::shared_ptr<postings_data_type>> cache_;
75 };
76 }
77 }
78 
79 #include "index/cached_index.tcc"
80 #endif
void clear_cache()
Clears the cache for the index.
Definition: cached_index.tcc:34
Decorator class for wrapping indexes with a cache.
Definition: cached_index.h:30
Cache< primary_key_type, std::shared_ptr< postings_data_type > > cache_
The internal cache object.
Definition: cached_index.h:74
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
virtual std::shared_ptr< postings_data_type > search_primary(primary_key_type p_id) const override
Overload for search_primary() that first attempts to find the result in the cache.
Definition: cached_index.tcc:22
cached_index(cpptoml::table &config, Args &&...args)
Forwarding constructor: construct the Index part using the config, but then forward the additional ar...
Definition: cached_index.tcc:15
Definition: analyzer.h:19