Storage Engine API
mongo::FastMapNoAlloc< KeyType, ValueType > Class Template Reference

NOTE: This structure should not be used for anything other than the Lock Manager. More...

#include <fast_map_noalloc.h>

Detailed Description

template<class KeyType, class ValueType>
class mongo::FastMapNoAlloc< KeyType, ValueType >

NOTE: This structure should not be used for anything other than the Lock Manager.

This is a simple implementation of an unordered associative array with minimal functionality, used by the lock manager. It keeps a small number of memory entries to store values, in order to avoid memory allocations, which dominate the cost of the lock manager calls by a wide margin.

This class is not thread-safe.

Note: this custom data structure is necessary because we need: fast memory access; to maintain all data pointer/reference validity when entries are added/removed; and to avoid costly and repetitive entry mallocs and frees.

Classes

class  IteratorImpl
 Forward-only iterator. More...
 
struct  PreallocEntry
 Map entry through which we avoid releasing memory: we mark it as inUse or not. More...
 

Public Types

typedef IteratorImpl< FastMapNoAlloc< KeyType, ValueType >, ValueType, map_iteratorIterator
 
typedef IteratorImpl< const FastMapNoAlloc< KeyType, ValueType >, const ValueType, const_map_iteratorConstIterator
 

Public Member Functions

 FastMapNoAlloc ()
 
Iterator insert (const KeyType &key)
 Inserts the specified entry in the map and returns a reference to the memory for the entry just inserted. More...
 
Iterator begin ()
 Returns an iterator to the first element in the map. More...
 
ConstIterator begin () const
 
Iterator find (const KeyType &key)
 Returns an iterator pointing to the first position, which has entry with the specified key. More...
 
ConstIterator find (const KeyType &key) const
 
size_t size () const
 
bool empty () const
 

Private Types

typedef std::deque< PreallocEntryContainer
 
typedef Container::size_type size_type
 
typedef Container::iterator map_iterator
 
typedef Container::const_iterator const_map_iterator
 

Private Attributes

std::deque< PreallocEntry_fastAccess
 
size_type _fastAccessUsedSize
 

Member Typedef Documentation

◆ const_map_iterator

template<class KeyType, class ValueType>
typedef Container::const_iterator mongo::FastMapNoAlloc< KeyType, ValueType >::const_map_iterator
private

◆ ConstIterator

template<class KeyType, class ValueType>
typedef IteratorImpl<const FastMapNoAlloc<KeyType, ValueType>, const ValueType, const_map_iterator> mongo::FastMapNoAlloc< KeyType, ValueType >::ConstIterator

◆ Container

template<class KeyType, class ValueType>
typedef std::deque<PreallocEntry> mongo::FastMapNoAlloc< KeyType, ValueType >::Container
private

◆ Iterator

template<class KeyType, class ValueType>
typedef IteratorImpl<FastMapNoAlloc<KeyType, ValueType>, ValueType, map_iterator> mongo::FastMapNoAlloc< KeyType, ValueType >::Iterator

◆ map_iterator

template<class KeyType, class ValueType>
typedef Container::iterator mongo::FastMapNoAlloc< KeyType, ValueType >::map_iterator
private

◆ size_type

template<class KeyType, class ValueType>
typedef Container::size_type mongo::FastMapNoAlloc< KeyType, ValueType >::size_type
private

Constructor & Destructor Documentation

◆ FastMapNoAlloc()

template<class KeyType, class ValueType>
mongo::FastMapNoAlloc< KeyType, ValueType >::FastMapNoAlloc ( )
inline

Member Function Documentation

◆ begin() [1/2]

template<class KeyType, class ValueType>
Iterator mongo::FastMapNoAlloc< KeyType, ValueType >::begin ( )
inline

Returns an iterator to the first element in the map.

◆ begin() [2/2]

template<class KeyType, class ValueType>
ConstIterator mongo::FastMapNoAlloc< KeyType, ValueType >::begin ( ) const
inline

◆ empty()

template<class KeyType, class ValueType>
bool mongo::FastMapNoAlloc< KeyType, ValueType >::empty ( ) const
inline

◆ find() [1/2]

template<class KeyType, class ValueType>
Iterator mongo::FastMapNoAlloc< KeyType, ValueType >::find ( const KeyType &  key)
inline

Returns an iterator pointing to the first position, which has entry with the specified key.

Before dereferencing the returned iterator, it should be checked for validity using the finished() method or the ! operator. If no element was found, finished() will return true.

While it is allowed to call next() on the returned iterator, this is not very useful, because the container is not ordered.

◆ find() [2/2]

template<class KeyType, class ValueType>
ConstIterator mongo::FastMapNoAlloc< KeyType, ValueType >::find ( const KeyType &  key) const
inline

◆ insert()

template<class KeyType, class ValueType>
Iterator mongo::FastMapNoAlloc< KeyType, ValueType >::insert ( const KeyType &  key)
inline

Inserts the specified entry in the map and returns a reference to the memory for the entry just inserted.

◆ size()

template<class KeyType, class ValueType>
size_t mongo::FastMapNoAlloc< KeyType, ValueType >::size ( ) const
inline

Member Data Documentation

◆ _fastAccess

template<class KeyType, class ValueType>
std::deque<PreallocEntry> mongo::FastMapNoAlloc< KeyType, ValueType >::_fastAccess
private

◆ _fastAccessUsedSize

template<class KeyType, class ValueType>
size_type mongo::FastMapNoAlloc< KeyType, ValueType >::_fastAccessUsedSize
private

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