![]() |
Storage Engine API
|
NOTE: This structure should not be used for anything other than the Lock Manager. More...
#include <fast_map_noalloc.h>
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_iterator > | Iterator |
typedef IteratorImpl< const FastMapNoAlloc< KeyType, ValueType >, const ValueType, const_map_iterator > | ConstIterator |
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< PreallocEntry > | Container |
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 |
|
private |
typedef IteratorImpl<const FastMapNoAlloc<KeyType, ValueType>, const ValueType, const_map_iterator> mongo::FastMapNoAlloc< KeyType, ValueType >::ConstIterator |
|
private |
typedef IteratorImpl<FastMapNoAlloc<KeyType, ValueType>, ValueType, map_iterator> mongo::FastMapNoAlloc< KeyType, ValueType >::Iterator |
|
private |
|
private |
|
inline |
|
inline |
Returns an iterator to the first element in the map.
|
inline |
|
inline |
|
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.
|
inline |
|
inline |
Inserts the specified entry in the map and returns a reference to the memory for the entry just inserted.
|
inline |
|
private |
|
private |