![]() |
Storage Engine API
|
This interface is a work in progress. More...
#include <sorted_data_interface.h>
This interface is a work in progress.
Notes below:
This interface began as the SortedDataInterface, a way to hide the fact that there were two on-disk formats for the btree. With the introduction of other storage engines, this interface was generalized to provide access to sorted data. Specifically:
TODO: See if there is actually a performance gain.
TODO: See if this actually works.
Classes | |
class | Cursor |
Navigates over the sorted data. More... | |
Public Member Functions | |
virtual | ~SortedDataInterface () |
virtual SortedDataBuilderInterface * | getBulkBuilder (OperationContext *opCtx, bool dupsAllowed)=0 |
Return a bulk builder for 'this' index. More... | |
virtual Status | insert (OperationContext *opCtx, const BSONObj &key, const RecordId &loc, bool dupsAllowed)=0 |
Insert an entry into the index with the specified key and RecordId. More... | |
virtual void | unindex (OperationContext *opCtx, const BSONObj &key, const RecordId &loc, bool dupsAllowed)=0 |
Remove the entry from the index with the specified key and RecordId. More... | |
virtual Status | dupKeyCheck (OperationContext *opCtx, const BSONObj &key, const RecordId &loc)=0 |
Return ErrorCodes::DuplicateKey if 'key' already exists in 'this' index at a RecordId other than 'loc', and Status::OK() otherwise. More... | |
virtual Status | compact (OperationContext *opCtx) |
Attempt to reduce the storage space used by this index via compaction. More... | |
virtual void | fullValidate (OperationContext *opCtx, long long *numKeysOut, ValidateResults *fullResults) const =0 |
TODO: expose full set of args for testing? More... | |
virtual bool | appendCustomStats (OperationContext *opCtx, BSONObjBuilder *output, double scale) const =0 |
virtual long long | getSpaceUsedBytes (OperationContext *opCtx) const =0 |
Return the number of bytes consumed by 'this' index. More... | |
virtual bool | isEmpty (OperationContext *opCtx)=0 |
Return true if 'this' index is empty, and false otherwise. More... | |
virtual Status | touch (OperationContext *opCtx) const |
Attempt to bring the entirety of 'this' index into memory. More... | |
virtual long long | numEntries (OperationContext *opCtx) const |
Return the number of entries in 'this' index. More... | |
virtual std::unique_ptr< Cursor > | newCursor (OperationContext *opCtx, bool isForward=true) const =0 |
Returns an unpositioned cursor over 'this' index. More... | |
virtual std::unique_ptr< Cursor > | newRandomCursor (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... | |
virtual Status | initAsEmpty (OperationContext *opCtx)=0 |
|
inlinevirtual |
|
pure virtual |
Implemented in mongo::DevNullSortedDataInterface, mongo::WiredTigerIndex, and mongo::MobileIndex.
|
inlinevirtual |
Attempt to reduce the storage space used by this index via compaction.
Only called if the indexed record store supports compaction-in-place.
Reimplemented in mongo::WiredTigerIndex.
|
pure virtual |
Return ErrorCodes::DuplicateKey if 'key' already exists in 'this' index at a RecordId other than 'loc', and Status::OK() otherwise.
opCtx | the transaction under which this operation takes place |
TODO: Hide this by exposing an update method?
Implemented in mongo::DevNullSortedDataInterface, mongo::WiredTigerIndex, and mongo::MobileIndex.
|
pure virtual |
TODO: expose full set of args for testing?
Implemented in mongo::DevNullSortedDataInterface, mongo::WiredTigerIndex, and mongo::MobileIndex.
|
pure virtual |
Return a bulk builder for 'this' index.
Implementations can assume that 'this' index outlives its bulk builder.
opCtx | the transaction under which keys are added to 'this' index |
dupsAllowed | true if duplicate keys are allowed, and false otherwise |
Implemented in mongo::WiredTigerIndexStandard, mongo::WiredTigerIndexUnique, mongo::DevNullSortedDataInterface, mongo::MobileIndexUnique, and mongo::MobileIndexStandard.
|
pure virtual |
Return the number of bytes consumed by 'this' index.
opCtx | the transaction under which this operation takes place |
Implemented in mongo::DevNullSortedDataInterface, mongo::WiredTigerIndex, and mongo::MobileIndex.
|
pure virtual |
Implemented in mongo::DevNullSortedDataInterface, mongo::WiredTigerIndex, and mongo::MobileIndex.
|
pure virtual |
Insert an entry into the index with the specified key and RecordId.
opCtx | the transaction under which the insert takes place |
dupsAllowed | true if duplicate keys are allowed, and false otherwise |
ErrorCodes::DuplicateKey if 'key' already exists in 'this' index at a RecordId other than 'loc' and duplicates were not allowed
Implemented in mongo::DevNullSortedDataInterface, mongo::WiredTigerIndex, and mongo::MobileIndex.
|
pure virtual |
Return true if 'this' index is empty, and false otherwise.
Implemented in mongo::DevNullSortedDataInterface, mongo::WiredTigerIndex, and mongo::MobileIndex.
|
pure virtual |
Returns an unpositioned cursor over 'this' index.
Implementations can assume that 'this' index outlives all cursors it produces.
Implemented in mongo::WiredTigerIndexStandard, mongo::DevNullSortedDataInterface, mongo::WiredTigerIndexUnique, mongo::MobileIndexUnique, and mongo::MobileIndexStandard.
|
inlinevirtual |
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 {}.
Note if it is possible to implement RecordStore::getRandomCursor(), that method is preferred, as it will return the entire document, whereas this method will only return the index key and the RecordId, requiring an extra lookup.
This method may be implemented using a pseudo-random walk over B-trees or a similar approach. Different cursors should return entries in a different order. Random cursors may return the same entry more than once and, as a result, may return more entries than exist in the index. Implementations should avoid obvious biases toward older, newer, larger smaller or other specific classes of entries.
|
inlinevirtual |
Return the number of entries in 'this' index.
The default implementation should be overridden with a more efficient one if at all possible.
Reimplemented in mongo::MobileIndex.
|
inlinevirtual |
Attempt to bring the entirety of 'this' index into memory.
If the underlying storage engine does not support the operation, returns ErrorCodes::CommandNotSupported
Reimplemented in mongo::WiredTigerIndex.
|
pure virtual |
Remove the entry from the index with the specified key and RecordId.
opCtx | the transaction under which the remove takes place |
dupsAllowed | true if duplicate keys are allowed, and false otherwise |
Implemented in mongo::DevNullSortedDataInterface, mongo::WiredTigerIndex, and mongo::MobileIndex.