Storage Engine API
mongo::KVPrefix Class Reference

A KVPrefix may be prepended to the keys of entries in an underlying KV store. More...

#include <kv_prefix.h>

Detailed Description

A KVPrefix may be prepended to the keys of entries in an underlying KV store.

Prefixing keys as such allows multiple MongoDB collections share an underlying table. This can be a beneficial tradeoff for workloads that create many collections.

Public Member Functions

bool isPrefixed () const
 
int64_t toBSONValue () const
 
int64_t repr () const
 
std::string toString () const
 
bool operator< (const KVPrefix &rhs) const
 
bool operator== (const KVPrefix &rhs) const
 
bool operator!= (const KVPrefix &rhs) const
 

Static Public Member Functions

static KVPrefix fromBSONElement (const BSONElement value)
 
static void setLargestPrefix (KVPrefix largestPrefix)
 
static KVPrefix getNextPrefix (const NamespaceString &ns)
 Returns 'KVPrefix::kNotPrefixed' if 'storageGlobalParams.groupCollections' is false or the input 'ns' is a namespace disallowed for grouping. More...
 
static KVPrefix generateNextPrefix ()
 Unconditionally returns a new prefix. More...
 

Static Public Attributes

static const KVPrefix kNotPrefixed = KVPrefix(-1)
 

Private Member Functions

 KVPrefix (int64_t value)
 

Private Attributes

int64_t _value
 

Static Private Attributes

static stdx::mutex _nextValueMutex
 
static int64_t _nextValue = 0
 

Constructor & Destructor Documentation

◆ KVPrefix()

mongo::KVPrefix::KVPrefix ( int64_t  value)
inlineexplicitprivate

Member Function Documentation

◆ fromBSONElement()

KVPrefix mongo::KVPrefix::fromBSONElement ( const BSONElement  value)
static

◆ generateNextPrefix()

KVPrefix mongo::KVPrefix::generateNextPrefix ( )
static

Unconditionally returns a new prefix.

Only useful for testing.

◆ getNextPrefix()

KVPrefix mongo::KVPrefix::getNextPrefix ( const NamespaceString &  ns)
static

Returns 'KVPrefix::kNotPrefixed' if 'storageGlobalParams.groupCollections' is false or the input 'ns' is a namespace disallowed for grouping.

Otherwise returns the next 'KVPrefix' ensuring it is unique with respect to active collections and indexes.

◆ isPrefixed()

bool mongo::KVPrefix::isPrefixed ( ) const
inline

◆ operator!=()

bool mongo::KVPrefix::operator!= ( const KVPrefix rhs) const
inline

◆ operator<()

bool mongo::KVPrefix::operator< ( const KVPrefix rhs) const
inline

◆ operator==()

bool mongo::KVPrefix::operator== ( const KVPrefix rhs) const
inline

◆ repr()

int64_t mongo::KVPrefix::repr ( ) const
inline

◆ setLargestPrefix()

void mongo::KVPrefix::setLargestPrefix ( KVPrefix  largestPrefix)
static

◆ toBSONValue()

int64_t mongo::KVPrefix::toBSONValue ( ) const
inline

◆ toString()

std::string mongo::KVPrefix::toString ( ) const

Member Data Documentation

◆ _nextValue

int64_t mongo::KVPrefix::_nextValue = 0
staticprivate

◆ _nextValueMutex

stdx::mutex mongo::KVPrefix::_nextValueMutex
staticprivate

◆ _value

int64_t mongo::KVPrefix::_value
private

◆ kNotPrefixed

const KVPrefix mongo::KVPrefix::kNotPrefixed = KVPrefix(-1)
static

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