ModErn Text Analysis
META Enumerates Textual Applications
Public Types | Public Member Functions | Private Attributes | List of all members
meta::index::cached_index< Index, Cache > Class Template Reference

Decorator class for wrapping indexes with a cache. More...

#include <cached_index.h>

Inheritance diagram for meta::index::cached_index< Index, Cache >:

Public Types

using primary_key_type = typename Index::primary_key_type
 
using secondary_key_type = typename Index::secondary_key_type
 
using postings_data_type = typename Index::postings_data_type
 

Public Member Functions

template<class... Args>
 cached_index (cpptoml::table &config, Args &&...args)
 Forwarding constructor: construct the Index part using the config, but then forward the additional arguments to the underlying cache. More...
 
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. More...
 
void clear_cache ()
 Clears the cache for the index. More...
 

Private Attributes

Cache< primary_key_type, std::shared_ptr< postings_data_type > > cache_
 The internal cache object.
 

Detailed Description

template<class Index, template< class, class > class Cache>
class meta::index::cached_index< Index, Cache >

Decorator class for wrapping indexes with a cache.

Like other indexes, you shouldn't construct this directly, but rather use make_index().

Constructor & Destructor Documentation

template<class Index , template< class, class > class Cache>
template<class... Args>
meta::index::cached_index< Index, Cache >::cached_index ( cpptoml::table &  config,
Args &&...  args 
)

Forwarding constructor: construct the Index part using the config, but then forward the additional arguments to the underlying cache.

Parameters
configthe configuration that specifies how the index should be constructed
argsThe remaining arguments to send to the Cache constructor

Member Function Documentation

template<class Index , template< class, class > class Cache>
auto meta::index::cached_index< Index, Cache >::search_primary ( primary_key_type  p_id) const
overridevirtual

Overload for search_primary() that first attempts to find the result in the cache.

Failing that, it will invoke the base class search_primary(), store the result in the cache, and then return the value.

Parameters
p_idthe primary key to search the postings file for
template<class Index , template< class, class > class Cache>
void meta::index::cached_index< Index, Cache >::clear_cache ( )

Clears the cache for the index.

Useful if you're using something like no-evict cache and want to reclaim memory.


The documentation for this class was generated from the following files: