Storage Engine API
mongo::MobileIndex Class Referenceabstract

#include <mobile_index.h>

Inheritance diagram for mongo::MobileIndex:
mongo::SortedDataInterface mongo::MobileIndexStandard mongo::MobileIndexUnique

Classes

class  BulkBuilderBase
 
class  BulkBuilderStandard
 Bulk builds a non-unique index. More...
 
class  BulkBuilderUnique
 Bulk builds a unique index. More...
 

Public Member Functions

 MobileIndex (OperationContext *opCtx, const IndexDescriptor *desc, const std::string &ident)
 
 MobileIndex (bool isUnique, const Ordering &ordering, const std::string &ident)
 
virtual ~MobileIndex ()
 
Status insert (OperationContext *opCtx, const BSONObj &key, const RecordId &recId, bool dupsAllowed) override
 Insert an entry into the index with the specified key and RecordId. More...
 
void unindex (OperationContext *opCtx, const BSONObj &key, const RecordId &recId, bool dupsAllowed) override
 Remove the entry from the index with the specified key and RecordId. More...
 
void fullValidate (OperationContext *opCtx, long long *numKeysOut, ValidateResults *fullResults) const override
 Note: this validates the entire database file, not just the table used by this index. More...
 
bool appendCustomStats (OperationContext *opCtx, BSONObjBuilder *output, double scale) const override
 
long long getSpaceUsedBytes (OperationContext *opCtx) const override
 Return the number of bytes consumed by 'this' index. More...
 
long long numEntries (OperationContext *opCtx) const override
 Return the number of entries in 'this' index. More...
 
bool isEmpty (OperationContext *opCtx) override
 Return true if 'this' index is empty, and false otherwise. More...
 
Status initAsEmpty (OperationContext *opCtx) override
 
Status dupKeyCheck (OperationContext *opCtx, const BSONObj &key, const RecordId &recId) override
 Return ErrorCodes::DuplicateKey if 'key' already exists in 'this' index at a RecordId other than 'loc', and Status::OK() otherwise. More...
 
template<typename ValueType >
Status doInsert (OperationContext *opCtx, const KeyString &key, const ValueType &value, bool isTransactional=true)
 Performs the insert into the table with the given key and value. More...
 
Ordering getOrdering () const
 
KeyString::Version getKeyStringVersion () const
 
bool isUnique ()
 
std::string getIdent () const
 
- Public Member Functions inherited from mongo::SortedDataInterface
virtual ~SortedDataInterface ()
 
virtual SortedDataBuilderInterfacegetBulkBuilder (OperationContext *opCtx, bool dupsAllowed)=0
 Return a bulk builder for 'this' index. More...
 
virtual Status compact (OperationContext *opCtx)
 Attempt to reduce the storage space used by this index via compaction. More...
 
virtual Status touch (OperationContext *opCtx) const
 Attempt to bring the entirety of 'this' index into memory. More...
 
virtual std::unique_ptr< CursornewCursor (OperationContext *opCtx, bool isForward=true) const =0
 Returns an unpositioned cursor over 'this' index. More...
 
virtual std::unique_ptr< CursornewRandomCursor (OperationContext *opCtx) const
 Constructs a cursor over an index that returns entries in a randomized order, and allows storage engines to provide a more efficient way to randomly sample a collection than MongoDB's default sampling methods, which are used when this method returns {}. More...
 

Static Public Member Functions

static Status create (OperationContext *opCtx, const std::string &ident)
 Creates a SQLite table suitable for a new Mobile index. More...
 

Protected Member Functions

bool _isDup (OperationContext *opCtx, const BSONObj &key, RecordId recId)
 
Status _dupKeyError (const BSONObj &key)
 
void _doDelete (OperationContext *opCtx, const KeyString &key, KeyString *value=nullptr)
 Performs the deletion from the table matching the given key. More...
 
virtual Status _insert (OperationContext *opCtx, const BSONObj &key, const RecordId &recId, bool dupsAllowed)=0
 
virtual void _unindex (OperationContext *opCtx, const BSONObj &key, const RecordId &recId, bool dupsAllowed)=0
 

Static Protected Member Functions

static Status _checkKeySize (const BSONObj &key)
 Checks if key size is too long. More...
 

Protected Attributes

const bool _isUnique
 
const Ordering _ordering
 
const KeyString::Version _keyStringVersion = KeyString::kLatestVersion
 
const std::string _ident
 

Constructor & Destructor Documentation

◆ MobileIndex() [1/2]

mongo::MobileIndex::MobileIndex ( OperationContext *  opCtx,
const IndexDescriptor *  desc,
const std::string &  ident 
)

◆ MobileIndex() [2/2]

mongo::MobileIndex::MobileIndex ( bool  isUnique,
const Ordering &  ordering,
const std::string &  ident 
)

◆ ~MobileIndex()

virtual mongo::MobileIndex::~MobileIndex ( )
inlinevirtual

Member Function Documentation

◆ _checkKeySize()

Status mongo::MobileIndex::_checkKeySize ( const BSONObj &  key)
staticprotected

Checks if key size is too long.

◆ _doDelete()

void mongo::MobileIndex::_doDelete ( OperationContext *  opCtx,
const KeyString key,
KeyString value = nullptr 
)
protected

Performs the deletion from the table matching the given key.

◆ _dupKeyError()

Status mongo::MobileIndex::_dupKeyError ( const BSONObj &  key)
protected

◆ _insert()

virtual Status mongo::MobileIndex::_insert ( OperationContext *  opCtx,
const BSONObj &  key,
const RecordId &  recId,
bool  dupsAllowed 
)
protectedpure virtual

◆ _isDup()

bool mongo::MobileIndex::_isDup ( OperationContext *  opCtx,
const BSONObj &  key,
RecordId  recId 
)
protected

◆ _unindex()

virtual void mongo::MobileIndex::_unindex ( OperationContext *  opCtx,
const BSONObj &  key,
const RecordId &  recId,
bool  dupsAllowed 
)
protectedpure virtual

◆ appendCustomStats()

bool mongo::MobileIndex::appendCustomStats ( OperationContext *  opCtx,
BSONObjBuilder *  output,
double  scale 
) const
overridevirtual

◆ create()

Status mongo::MobileIndex::create ( OperationContext *  opCtx,
const std::string &  ident 
)
static

Creates a SQLite table suitable for a new Mobile index.

◆ doInsert()

template<typename ValueType >
Status mongo::MobileIndex::doInsert ( OperationContext *  opCtx,
const KeyString key,
const ValueType &  value,
bool  isTransactional = true 
)

Performs the insert into the table with the given key and value.

◆ dupKeyCheck()

Status mongo::MobileIndex::dupKeyCheck ( OperationContext *  opCtx,
const BSONObj &  key,
const RecordId &  loc 
)
overridevirtual

Return ErrorCodes::DuplicateKey if 'key' already exists in 'this' index at a RecordId other than 'loc', and Status::OK() otherwise.

Parameters
opCtxthe transaction under which this operation takes place

TODO: Hide this by exposing an update method?

Implements mongo::SortedDataInterface.

◆ fullValidate()

void mongo::MobileIndex::fullValidate ( OperationContext *  opCtx,
long long *  numKeysOut,
ValidateResults fullResults 
) const
overridevirtual

Note: this validates the entire database file, not just the table used by this index.

Implements mongo::SortedDataInterface.

◆ getIdent()

std::string mongo::MobileIndex::getIdent ( ) const
inline

◆ getKeyStringVersion()

KeyString::Version mongo::MobileIndex::getKeyStringVersion ( ) const
inline

◆ getOrdering()

Ordering mongo::MobileIndex::getOrdering ( ) const
inline

◆ getSpaceUsedBytes()

long long mongo::MobileIndex::getSpaceUsedBytes ( OperationContext *  opCtx) const
overridevirtual

Return the number of bytes consumed by 'this' index.

Parameters
opCtxthe transaction under which this operation takes place
See also
IndexAccessMethod::getSpaceUsedBytes

Implements mongo::SortedDataInterface.

◆ initAsEmpty()

Status mongo::MobileIndex::initAsEmpty ( OperationContext *  opCtx)
overridevirtual

◆ insert()

Status mongo::MobileIndex::insert ( OperationContext *  opCtx,
const BSONObj &  key,
const RecordId &  loc,
bool  dupsAllowed 
)
overridevirtual

Insert an entry into the index with the specified key and RecordId.

Parameters
opCtxthe transaction under which the insert takes place
dupsAllowedtrue if duplicate keys are allowed, and false otherwise
Returns
Status::OK() if the insert succeeded,
    ErrorCodes::DuplicateKey if 'key' already exists in 'this' index
    at a RecordId other than 'loc' and duplicates were not allowed

Implements mongo::SortedDataInterface.

◆ isEmpty()

bool mongo::MobileIndex::isEmpty ( OperationContext *  opCtx)
overridevirtual

Return true if 'this' index is empty, and false otherwise.

Implements mongo::SortedDataInterface.

◆ isUnique()

bool mongo::MobileIndex::isUnique ( )
inline

◆ numEntries()

long long mongo::MobileIndex::numEntries ( OperationContext *  opCtx) const
overridevirtual

Return the number of entries in 'this' index.

The default implementation should be overridden with a more efficient one if at all possible.

Reimplemented from mongo::SortedDataInterface.

◆ unindex()

void mongo::MobileIndex::unindex ( OperationContext *  opCtx,
const BSONObj &  key,
const RecordId &  loc,
bool  dupsAllowed 
)
overridevirtual

Remove the entry from the index with the specified key and RecordId.

Parameters
opCtxthe transaction under which the remove takes place
dupsAllowedtrue if duplicate keys are allowed, and false otherwise

Implements mongo::SortedDataInterface.

Member Data Documentation

◆ _ident

const std::string mongo::MobileIndex::_ident
protected

◆ _isUnique

const bool mongo::MobileIndex::_isUnique
protected

◆ _keyStringVersion

const KeyString::Version mongo::MobileIndex::_keyStringVersion = KeyString::kLatestVersion
protected

◆ _ordering

const Ordering mongo::MobileIndex::_ordering
protected

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