Storage Engine API
mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner > Class Template Reference

A templated class used to partition an associative container like a set or a map to increase scalability. More...

#include <partitioned.h>

Detailed Description

template<typename AssociativeContainer, std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
class mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >

A templated class used to partition an associative container like a set or a map to increase scalability.

AssociativeContainer is a type like a std::map or std::set that meets the requirements of either the AssociativeContainer or UnorderedAssociativeContainer concept. nPartitions determines how many partitions to make. Partitioner can be provided to customize how the partition of each entry is computed.

Classes

class  All
 Used to protect access to all partitions of this partitioned associative structure. More...
 
struct  IteratorEndTag
 
class  OnePartition
 Used to protect access to a single partition of a Partitioned. More...
 

Public Types

using value_type = typename AssociativeContainer::value_type
 
using key_type = typename AssociativeContainer::key_type
 
using PartitionId = std::size_t
 

Public Member Functions

 Partitioned ()
 Constructs a partitioned version of a AssociativeContainer, with nPartitions partitions. More...
 
 Partitioned (const Partitioned &)=delete
 
 Partitioned (Partitioned &&)=default
 
Partitionedoperator= (const Partitioned &)=delete
 
Partitionedoperator= (Partitioned &&)=default
 
 ~Partitioned ()=default
 
bool empty () const
 Returns true if each partition is empty. More...
 
std::size_t size () const
 Returns the number of elements in all partitions, summed together. More...
 
std::size_t count (const key_type &key) &
 Returns the number of entries with the given key. More...
 
void count (const key_type &) &&=delete
 
void clear ()
 Empties all partitions. More...
 
void insert (const value_type value) &
 Inserts a single value into the partitioned structure. More...
 
void insert (const value_type) &&=delete
 
std::size_t erase (const key_type &key) &
 Erases one entry from the partitioned structure. More...
 
void erase (const key_type &) &&=delete
 
All lockAllPartitions () &
 
OnePartition lockOnePartition (const key_type key) &
 
OnePartition lockOnePartitionById (PartitionId id) &
 

Private Types

using CacheAlignedAssociativeContainer = CacheAligned< AssociativeContainer >
 
template<typename T >
using AlignedVector = std::vector< T, boost::alignment::aligned_allocator< T > >
 

Private Attributes

AlignedVector< partitioned_detail::CacheAlignedMutex_mutexes
 
AlignedVector< CacheAlignedAssociativeContainer_partitions
 

Member Typedef Documentation

◆ AlignedVector

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
template<typename T >
using mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::AlignedVector = std::vector<T, boost::alignment::aligned_allocator<T> >
private

◆ CacheAlignedAssociativeContainer

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
using mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::CacheAlignedAssociativeContainer = CacheAligned<AssociativeContainer>
private

◆ key_type

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
using mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::key_type = typename AssociativeContainer::key_type

◆ PartitionId

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
using mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::PartitionId = std::size_t

◆ value_type

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
using mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::value_type = typename AssociativeContainer::value_type

Constructor & Destructor Documentation

◆ Partitioned() [1/3]

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::Partitioned ( )
inline

Constructs a partitioned version of a AssociativeContainer, with nPartitions partitions.

◆ Partitioned() [2/3]

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::Partitioned ( const Partitioned< AssociativeContainer, nPartitions, KeyPartitioner > &  )
delete

◆ Partitioned() [3/3]

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::Partitioned ( Partitioned< AssociativeContainer, nPartitions, KeyPartitioner > &&  )
default

◆ ~Partitioned()

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::~Partitioned ( )
default

Member Function Documentation

◆ clear()

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
void mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::clear ( )
inline

Empties all partitions.

◆ count() [1/2]

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
std::size_t mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::count ( const key_type key) &
inline

Returns the number of entries with the given key.

Acquires locks for only the partition determined by that key.

◆ count() [2/2]

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
void mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::count ( const key_type ) &&
delete

◆ empty()

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
bool mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::empty ( ) const
inline

Returns true if each partition is empty.

Locks the all partitions to perform this check, but insertions can occur as soon as this method returns.

◆ erase() [1/2]

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
std::size_t mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::erase ( const key_type key) &
inline

Erases one entry from the partitioned structure.

Locks only the partition given by the key. Returns the number of entries removed.

◆ erase() [2/2]

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
void mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::erase ( const key_type ) &&
delete

◆ insert() [1/2]

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
void mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::insert ( const value_type  value) &
inline

Inserts a single value into the partitioned structure.

Locks a single partition determined by the value itself. Will not lock any partitions besides the one inserted into.

◆ insert() [2/2]

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
void mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::insert ( const value_type  ) &&
delete

◆ lockAllPartitions()

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
All mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::lockAllPartitions ( ) &
inline

◆ lockOnePartition()

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
OnePartition mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::lockOnePartition ( const key_type  key) &
inline

◆ lockOnePartitionById()

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
OnePartition mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::lockOnePartitionById ( PartitionId  id) &
inline

◆ operator=() [1/2]

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
Partitioned& mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::operator= ( const Partitioned< AssociativeContainer, nPartitions, KeyPartitioner > &  )
delete

◆ operator=() [2/2]

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
Partitioned& mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::operator= ( Partitioned< AssociativeContainer, nPartitions, KeyPartitioner > &&  )
default

◆ size()

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
std::size_t mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::size ( ) const
inline

Returns the number of elements in all partitions, summed together.

Locks all partitions to do this computation, but the size can change as soon as this method returns.

Member Data Documentation

◆ _mutexes

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
AlignedVector<partitioned_detail::CacheAlignedMutex> mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::_mutexes
mutableprivate

◆ _partitions

template<typename AssociativeContainer , std::size_t nPartitions = 16, typename KeyPartitioner = Partitioner<typename AssociativeContainer::key_type>>
AlignedVector<CacheAlignedAssociativeContainer> mongo::Partitioned< AssociativeContainer, nPartitions, KeyPartitioner >::_partitions
private

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