ddc
Public Types | Public Member Functions | Public Attributes | List of all members
NavHintCache Class Reference

LRU cache for faster "paging" through daughter hits for a branch server. More...

#include <NavHint.h>

Inheritance diagram for NavHintCache:
Inheritance graph
[legend]
Collaboration diagram for NavHintCache:
Collaboration graph
[legend]

Public Types

typedef NavHintKey KeyT
 navigation cache key type More...
 
typedef NavHint ValT
 navigation cache value type More...
 
typedef ddcLRUCache< KeyT, ValTCacheT
 typedef for underlying LRU cache object More...
 

Public Member Functions

 NavHintCache (size_t capacity=1024)
 
 ~NavHintCache ()
 default destructor (empty) More...
 
void reserve (size_t capacity_)
 wraps lock(); m_Cache.reserve(capacity_); unlock() More...
 
size_t size () const
 wraps lock(); m_Cache.size(); unlock() More...
 
void clear ()
 wraps lock(); m_Cache.clear(); unlock() More...
 
bool lower_bound (ValT &val, const KeyT &key, bool doPromote=true)
 
ValT lower_bound (const KeyT &key, bool doPromote=true)
 
void insert (const KeyT &key, const ValT &val)
 
ValT lower_bound (const string &QueryStr, size_t HitNo)
 wrapper for lower_bound(KeyT(QueryStr, HitNo)) More...
 
void insert (const string &QueryStr, size_t HitNo, const string &SortKey, const size_t Offset, const vector< string > &DtrHints)
 wrapper for insert(KeyT(QueryStr, HitNo), ValT(SortKey,Offset,DtrHints)) More...
 
string toJson () const
 debug: stringification More...
 
- Public Member Functions inherited from ddcLockable
 ddcLockable ()
 
virtual ~ddcLockable ()
 
int lock () const
 
int unlock () const
 

Public Attributes

CacheT m_Cache
 underlying LRU cache More...
 
- Public Attributes inherited from ddcLockable
pthread_mutex_t m_Mutex
 

Detailed Description

LRU cache for faster "paging" through daughter hits for a branch server.

Member Typedef Documentation

◆ KeyT

navigation cache key type

◆ ValT

navigation cache value type

◆ CacheT

typedef for underlying LRU cache object

Constructor & Destructor Documentation

◆ NavHintCache()

NavHintCache::NavHintCache ( size_t  capacity = 1024)
inline

default constructor

  • initializes m_Cache to use m_Mutex inherited from ddcLockable

◆ ~NavHintCache()

NavHintCache::~NavHintCache ( )
inline

default destructor (empty)

Member Function Documentation

◆ reserve()

void NavHintCache::reserve ( size_t  capacity_)
inline

wraps lock(); m_Cache.reserve(capacity_); unlock()

References ddcLRUCache< Key, Val >::reserve().

Here is the call graph for this function:

◆ size()

size_t NavHintCache::size ( void  ) const
inline

wraps lock(); m_Cache.size(); unlock()

References ddcLRUCache< Key, Val >::size().

Here is the call graph for this function:

◆ clear()

void NavHintCache::clear ( void  )
inline

wraps lock(); m_Cache.clear(); unlock()

References ddcLRUCache< Key, Val >::clear().

Here is the call graph for this function:

◆ lower_bound() [1/3]

bool NavHintCache::lower_bound ( ValT val,
const KeyT key,
bool  doPromote = true 
)

get lower bound for key key = (QueryStr,HitNo)

Returns
true iff a match was found in cache, false otherwise
  • copies lower-bound cached hint for key if QueryStr matches, otherwise clears hint
  • if a valid match is found, it is promoted to MRU position iff doPromote is true
  • wraps operation in lock() + unlock()
Parameters
val(output) hint to be extracted (data copied from cache if found, otherwise an empty hint)
key(input) key to search for
doPromote(input) whether to implicitly promote match to MRU position

References NavHint::clear(), ddcLogTrace, escapeCString(), Format(), NavHintKey::m_QueryStr, NAVCACHE_TRACE, and NavHintKey::toString().

Here is the call graph for this function:

◆ lower_bound() [2/3]

ValT NavHintCache::lower_bound ( const KeyT key,
bool  doPromote = true 
)
inline

get lower bound for key key = (QueryStr,HitNo)

Returns
copy of lower-bound cached hint for key if QueryStr matches, otherwise an empty hint for nSubs

◆ insert() [1/2]

void NavHintCache::insert ( const KeyT key,
const ValT val 
)
inline

insert new entry for key = (QueryStr,HitNo)

  • promotes new entry to MRU position
  • implicitly wraps operation in lock() + unlock()

References ddcLogTrace, escapeCString(), Format(), ddcLRUCache< Key, Val >::insert(), NAVCACHE_TRACE, NavHintKey::toString(), and NavHint::toString().

Here is the call graph for this function:

◆ lower_bound() [3/3]

ValT NavHintCache::lower_bound ( const string &  QueryStr,
size_t  HitNo 
)
inline

wrapper for lower_bound(KeyT(QueryStr, HitNo))

◆ insert() [2/2]

void NavHintCache::insert ( const string &  QueryStr,
size_t  HitNo,
const string &  SortKey,
const size_t  Offset,
const vector< string > &  DtrHints 
)
inline

wrapper for insert(KeyT(QueryStr, HitNo), ValT(SortKey,Offset,DtrHints))

References NavHintKey::toJson().

Here is the call graph for this function:

◆ toJson()

string NavHintCache::toJson ( ) const

debug: stringification

References Format(), listPos(), and NAVCACHE_VERBOSE_JSON.

Here is the call graph for this function:

Member Data Documentation

◆ m_Cache

CacheT NavHintCache::m_Cache

underlying LRU cache

Referenced by listPos().


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