![]() |
Storage Engine API
|
The WiredTigerSizeStorer class serves as a write buffer to durably store size information for MongoDB collections. More...
#include <wiredtiger_size_storer.h>
The WiredTigerSizeStorer class serves as a write buffer to durably store size information for MongoDB collections.
The size storer uses a separate WiredTiger table as key-value store, where the URI serves as key and the value is a BSON document with numRecords
and dataSize
fields. This buffering is neccessary to allow concurrent updates of size information without causing write conflicts. The dirty size information is periodically stored written back to the table, including on clean shutdown and/or catalog reload. Crashes or replica-set fail-overs may result in size updates to be lost, so size information is only approximate. Reads use the buffer for pending stores, or otherwise read directly from the WiredTiger table using a dedicated session and cursor.
Classes | |
struct | SizeInfo |
SizeInfo is a thread-safe buffer for keeping track of the number of documents in a collection and their data size. More... | |
Public Member Functions | |
WiredTigerSizeStorer (WT_CONNECTION *conn, const std::string &storageUri, const bool readOnly=false) | |
~WiredTigerSizeStorer () | |
void | store (StringData uri, std::shared_ptr< SizeInfo > sizeInfo) |
Ensure that the shared SizeInfo will be stored by the next call to flush. More... | |
std::shared_ptr< SizeInfo > | load (StringData uri) const |
void | flush (bool syncToDisk) |
Writes all changes to the underlying table. More... | |
Private Types | |
using | Buffer = StringMap< std::shared_ptr< SizeInfo > > |
Private Attributes | |
const WiredTigerSession | _session |
const bool | _readOnly |
stdx::mutex | _cursorMutex |
WT_CURSOR * | _cursor |
stdx::mutex | _bufferMutex |
Buffer | _buffer |
|
private |
mongo::WiredTigerSizeStorer::WiredTigerSizeStorer | ( | WT_CONNECTION * | conn, |
const std::string & | storageUri, | ||
const bool | readOnly = false |
||
) |
mongo::WiredTigerSizeStorer::~WiredTigerSizeStorer | ( | ) |
void mongo::WiredTigerSizeStorer::flush | ( | bool | syncToDisk | ) |
Writes all changes to the underlying table.
std::shared_ptr< WiredTigerSizeStorer::SizeInfo > mongo::WiredTigerSizeStorer::load | ( | StringData | uri | ) | const |
Ensure that the shared SizeInfo will be stored by the next call to flush.
Values stored are no older than the values at time of this call, but may be newer.
|
private |
|
mutableprivate |
|
private |
|
mutableprivate |
|
private |
|
private |