35 #include "mongo/db/operation_context.h" 39 #include "mongo/platform/atomic_word.h" 50 const std::string& path,
51 const std::string& ident,
54 const char*
name()
const override;
56 const std::string&
getIdent()
const override;
68 bool enforceQuota)
override;
72 const Timestamp* timestamps,
74 RecordId* idsOut)
override;
77 const RecordId& oldLocation,
86 const RecordId& recId,
88 const char* damageSource,
89 const mutablebson::DamageVector& damages)
override;
91 std::unique_ptr<SeekableRecordCursor>
getCursor(OperationContext*
opCtx,
92 bool forward)
const override;
115 BSONObjBuilder* output)
override;
118 BSONObjBuilder* result,
119 double scale)
const override;
121 Status touch(OperationContext*
opCtx, BSONObjBuilder* output)
const override;
124 BSONObjBuilder* extraInfo = NULL,
125 int infoLevel = 0)
const override;
132 const RecordId& startingPosition)
const override;
156 static void create(OperationContext*
opCtx,
const std::string& ident);
161 class TruncateChange;
164 class DataSizeChange;
195 const std::string& direction,
196 int64_t startRecId = 0);
Definition: record_store.h:665
bool _resetDataSizeIfNeeded(OperationContext *opCtx, int64_t newDataSize)
Resets _dataSize to the new value.
Definition: mobile_record_store.cpp:743
bool _resetNumRecsIfNeeded(OperationContext *opCtx, int64_t newNumRecs)
Resets _numRecords to the new value.
Definition: mobile_record_store.cpp:706
void _initNumRecsIfNeeded_inlock(OperationContext *opCtx) const
Fetches the number of records from the database.
Definition: mobile_record_store.cpp:252
Status touch(OperationContext *opCtx, BSONObjBuilder *output) const override
Load all data into cache.
Definition: mobile_record_store.cpp:660
AtomicLockStats stats
Definition: lock_state.cpp:92
ValidateCmdLevel
Definition: record_store.h:93
long long dataSize(OperationContext *opCtx) const override
The dataSize is an approximation of the sum of the sizes (in bytes) of the documents or entries in th...
Definition: mobile_record_store.cpp:246
long long numRecords(OperationContext *opCtx) const override
Total number of record in the RecordStore.
Definition: mobile_record_store.cpp:269
Definition: record_store.h:673
const bool _isCapped
Definition: mobile_record_store.h:203
Status validate(OperationContext *opCtx, ValidateCmdLevel level, ValidateAdaptor *adaptor, ValidateResults *results, BSONObjBuilder *output) override
Note: on full validation, this validates the entire database file, not just the table used by this re...
Definition: mobile_record_store.cpp:560
bool compactsInPlace() const override
Does compact() leave RecordIds alone or can they change.
Definition: mobile_record_store.h:102
A RecordStore that stores all data in SQLite.
Definition: mobile_record_store.h:46
Definition: collection_options.h:57
void _changeNumRecs(OperationContext *opCtx, int64_t diff)
Updates _numRecords.
Definition: mobile_record_store.cpp:699
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
void _cappedDeleteIfNeeded(OperationContext *opCtx)
Deletes records from a capped database if the cap is exceeded.
Definition: mobile_record_store.cpp:389
A replacement for the Record class.
Definition: record_data.h:43
int64_t _cappedMaxSize
Definition: mobile_record_store.h:204
void setCappedCallback(CappedCallback *cb) override
Definition: mobile_record_store.h:144
void _changeDataSize(OperationContext *opCtx, int64_t diff)
Updates _dataSize.
Definition: mobile_record_store.cpp:736
Status compact(OperationContext *opCtx, RecordStoreCompactAdaptor *adaptor, const CompactOptions *options, CompactStats *stats) override
Attempt to reduce the storage space used by this RecordStore.
Definition: mobile_record_store.cpp:549
bool _isCappedAndNeedsDelete(int64_t numRecs, int64_t numBytes)
Returns true if the collection is capped and exceeds the size or document cap.
Definition: mobile_record_store.cpp:323
const std::string _path
Definition: mobile_record_store.h:170
This is so when a RecordStore is validating all records it can call back to someone to check if a rec...
Definition: record_store.h:687
Definition: record_store.h:78
stdx::mutex _cappedCallbackMutex
Definition: mobile_record_store.h:207
std::unique_ptr< SeekableRecordCursor > getCursor(OperationContext *opCtx, bool forward) const override
Returns a new cursor over this record store.
Definition: mobile_record_store.cpp:497
Status updateRecord(OperationContext *opCtx, const RecordId &oldLocation, const char *data, int len, bool enforceQuota, UpdateNotifier *notifier) override
Definition: mobile_record_store.cpp:452
bool inclusive
Definition: btree_interface.cpp:335
int64_t _dataSize
Definition: mobile_record_store.h:250
StatusWith< RecordId > insertRecord(OperationContext *opCtx, const char *data, int len, Timestamp timestamp, bool enforceQuota) override
Definition: mobile_record_store.cpp:403
MobileRecordStore(OperationContext *opCtx, StringData ns, const std::string &path, const std::string &ident, const CollectionOptions &options)
Definition: mobile_record_store.cpp:193
bool _isDataSizeInitialized
Definition: mobile_record_store.h:252
Definition: collection.h:77
Allows inserting a Record "in-place" without creating a copy ahead of time.
Definition: record_store.h:62
std::shared_ptr< void > data
Definition: ephemeral_for_test_record_store_test.cpp:74
const std::string & getIdent() const override
Definition: mobile_record_store.cpp:226
void appendCustomStats(OperationContext *opCtx, BSONObjBuilder *result, double scale) const override
Definition: mobile_record_store.cpp:650
stdx::mutex _dataSizeMutex
Definition: mobile_record_store.h:251
bool isCapped() const override
Definition: mobile_record_store.h:140
Status insertRecordsWithDocWriter(OperationContext *opCtx, const DocWriter *const *docs, const Timestamp *timestamps, size_t nDocs, RecordId *idsOut) override
Inserts nDocs documents into this RecordStore using the DocWriter interface.
Definition: mobile_record_store.cpp:428
RecordData dataFor(OperationContext *opCtx, const RecordId &recId) const override
Get the RecordData at loc, which must exist.
Definition: mobile_record_store.cpp:275
OperationContext Database StringData CollectionOptions bool const BSONObj &idIndex Status
Definition: database_impl.cpp:955
Status updateCappedSize(OperationContext *opCtx, long long cappedSize) override
used to support online change oplog size.
Definition: mobile_record_store.cpp:755
void deleteRecord(OperationContext *opCtx, const RecordId &dl) override
Definition: mobile_record_store.cpp:303
Definition: index_key_validate.h:40
void cappedTruncateAfter(OperationContext *opCtx, RecordId end, bool inclusive) override
The method throws an assertion if the capped truncate results in an emptied table.
Definition: mobile_record_store.cpp:524
void _doCappedDelete(OperationContext *opCtx, SqliteStatement &stmt, const std::string &direction, int64_t startRecId=0)
Performs the capped deletion.
Definition: mobile_record_store.cpp:341
boost::optional< RecordId > oplogStartHack(OperationContext *opCtx, const RecordId &startingPosition) const override
Return the RecordId of an oplog entry as close to startingPosition as possible without being higher.
Definition: mobile_record_store.cpp:760
int64_t storageSize(OperationContext *opCtx, BSONObjBuilder *extraInfo=NULL, int infoLevel=0) const override
Note: does not accurately return the size of the table on disk.
Definition: mobile_record_store.cpp:668
An abstraction used for storing documents in a collection or entries in an index.
Definition: record_store.h:282
When a capped collection is modified (delete/insert/etc) then certain notifications need to be made,...
Definition: capped_callback.h:44
const std::string _ident
Definition: mobile_record_store.h:171
virtual const std::string & ns() const
Definition: record_store.h:295
CappedCallback * _cappedCallback
Definition: mobile_record_store.h:208
void _notifyCappedCallbackIfNeeded_inlock(OperationContext *opCtx, RecordId recId, const RecordData &recData)
Notifies the capped callback that a capped collection is about to delete a record.
Definition: mobile_record_store.cpp:331
RecordId _nextId()
Definition: mobile_record_store.cpp:674
SqliteStatement is a wrapper around the sqlite3_stmt object.
Definition: mobile_sqlite_statement.h:43
int64_t _numRecs
Definition: mobile_record_store.h:229
void waitForAllEarlierOplogWritesToBeVisible(OperationContext *opCtx) const override
Waits for all writes that completed before this call to be visible to forward scans.
Definition: mobile_record_store.h:134
const int64_t _cappedMaxDocs
Definition: mobile_record_store.h:205
Status truncate(OperationContext *opCtx) override
SQLite does not directly support truncate.
Definition: mobile_record_store.cpp:507
const bool _isOplog
Definition: mobile_record_store.h:174
Definition: collection.h:97
AtomicInt64 _nextIdNum
Definition: mobile_record_store.h:210
bool updateWithDamagesSupported() const override
Definition: mobile_record_store.cpp:484
bool compactSupported() const override
does this RecordStore support the compact operation?
Definition: mobile_record_store.h:98
void _initDataSizeIfNeeded_inlock(OperationContext *opCtx) const
Fetches the data size from the database.
Definition: mobile_record_store.cpp:230
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
bool findRecord(OperationContext *opCtx, const RecordId &recId, RecordData *rd) const override
Definition: mobile_record_store.cpp:282
stdx::mutex _numRecsMutex
Definition: mobile_record_store.h:230
StatusWith< RecordData > updateWithDamages(OperationContext *opCtx, const RecordId &recId, const RecordData &oldRec, const char *damageSource, const mutablebson::DamageVector &damages) override
Updates the record positioned at 'loc' in-place using the deltas described by 'damages'.
Definition: mobile_record_store.cpp:488
const char * name() const override
Definition: mobile_record_store.cpp:222
static void create(OperationContext *opCtx, const std::string &ident)
Creates a new record store inside SQLite.
Definition: mobile_record_store.cpp:769
bool _isNumRecsInitialized
Definition: mobile_record_store.h:231
void updateStatsAfterRepair(OperationContext *opCtx, long long numRecords, long long dataSize) override
Called after a repair operation is run with the recomputed numRecords and dataSize.
Definition: mobile_record_store.h:136