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 RecordData dataFor(OperationContext* opCtx,
const RecordId& recId)
const override;
60 void deleteRecord(OperationContext* opCtx,
const RecordId& dl)
override;
66 bool enforceQuota)
override;
70 const Timestamp* timestamps,
72 RecordId* idsOut)
override;
75 const RecordId& oldLocation,
84 const RecordId& recId,
86 const char* damageSource,
87 const mutablebson::DamageVector& damages)
override;
89 std::unique_ptr<SeekableRecordCursor>
getCursor(OperationContext* opCtx,
90 bool forward)
const override;
113 BSONObjBuilder* output)
override;
116 BSONObjBuilder* result,
117 double scale)
const override;
119 Status touch(OperationContext* opCtx, BSONObjBuilder* output)
const override;
122 BSONObjBuilder* extraInfo = NULL,
123 int infoLevel = 0)
const override;
125 long long dataSize(OperationContext* opCtx)
const override;
127 long long numRecords(OperationContext* opCtx)
const override;
130 const RecordId& startingPosition)
const override;
135 long long numRecords,
136 long long dataSize)
override {}
154 static void create(OperationContext* opCtx,
const std::string& ident);
159 class TruncateChange;
193 const std::string& direction,
194 int64_t startRecId = 0);
Definition: record_store.h:663
bool _resetDataSizeIfNeeded(OperationContext *opCtx, int64_t newDataSize)
Resets _dataSize to the new value.
Definition: mobile_record_store.cpp:740
bool _resetNumRecsIfNeeded(OperationContext *opCtx, int64_t newNumRecs)
Resets _numRecords to the new value.
Definition: mobile_record_store.cpp:703
void _initNumRecsIfNeeded_inlock(OperationContext *opCtx) const
Fetches the number of records from the database.
Definition: mobile_record_store.cpp:248
Status touch(OperationContext *opCtx, BSONObjBuilder *output) const override
Load all data into cache.
Definition: mobile_record_store.cpp:657
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:242
Keeps track of the total data size.
Definition: mobile_record_store.cpp:717
long long numRecords(OperationContext *opCtx) const override
Total number of record in the RecordStore.
Definition: mobile_record_store.cpp:265
Definition: record_store.h:671
const bool _isCapped
Definition: mobile_record_store.h:201
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:557
bool compactsInPlace() const override
Does compact() leave RecordIds alone or can they change.
Definition: mobile_record_store.h:100
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:696
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:386
OperationContext Database StringData BSONObj CollectionOptions::ParseKind bool const BSONObj &idIndex Status
Definition: database_impl.cpp:956
A replacement for the Record class.
Definition: record_data.h:43
int64_t _cappedMaxSize
Definition: mobile_record_store.h:202
void setCappedCallback(CappedCallback *cb) override
Definition: mobile_record_store.h:142
void _changeDataSize(OperationContext *opCtx, int64_t diff)
Updates _dataSize.
Definition: mobile_record_store.cpp:733
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:546
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:319
const std::string _path
Definition: mobile_record_store.h:168
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:685
Definition: record_store.h:78
stdx::mutex _cappedCallbackMutex
Definition: mobile_record_store.h:205
std::unique_ptr< SeekableRecordCursor > getCursor(OperationContext *opCtx, bool forward) const override
Returns a new cursor over this record store.
Definition: mobile_record_store.cpp:494
Status updateRecord(OperationContext *opCtx, const RecordId &oldLocation, const char *data, int len, bool enforceQuota, UpdateNotifier *notifier) override
Definition: mobile_record_store.cpp:449
bool inclusive
Definition: btree_interface.cpp:335
int64_t _dataSize
Definition: mobile_record_store.h:248
StatusWith< RecordId > insertRecord(OperationContext *opCtx, const char *data, int len, Timestamp timestamp, bool enforceQuota) override
Definition: mobile_record_store.cpp:400
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:250
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
void appendCustomStats(OperationContext *opCtx, BSONObjBuilder *result, double scale) const override
Definition: mobile_record_store.cpp:647
stdx::mutex _dataSizeMutex
Definition: mobile_record_store.h:249
bool isCapped() const override
Definition: mobile_record_store.h:138
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:425
RecordData dataFor(OperationContext *opCtx, const RecordId &recId) const override
Get the RecordData at loc, which must exist.
Definition: mobile_record_store.cpp:271
Status updateCappedSize(OperationContext *opCtx, long long cappedSize) override
used to support online change oplog size.
Definition: mobile_record_store.cpp:752
void deleteRecord(OperationContext *opCtx, const RecordId &dl) override
Definition: mobile_record_store.cpp:299
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:521
Definition: mobile_record_store.cpp:55
void _doCappedDelete(OperationContext *opCtx, SqliteStatement &stmt, const std::string &direction, int64_t startRecId=0)
Performs the capped deletion.
Definition: mobile_record_store.cpp:337
Keeps track of the changes to the number of records.
Definition: mobile_record_store.cpp:680
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:757
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:665
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:169
virtual const std::string & ns() const
Definition: record_store.h:295
CappedCallback * _cappedCallback
Definition: mobile_record_store.h:206
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:327
RecordId _nextId()
Definition: mobile_record_store.cpp:671
SqliteStatement is a wrapper around the sqlite3_stmt object.
Definition: mobile_sqlite_statement.h:42
int64_t _numRecs
Definition: mobile_record_store.h:227
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:132
const int64_t _cappedMaxDocs
Definition: mobile_record_store.h:203
Status truncate(OperationContext *opCtx) override
SQLite does not directly support truncate.
Definition: mobile_record_store.cpp:503
const bool _isOplog
Definition: mobile_record_store.h:172
OperationContext Database StringData BSONObj options
Definition: database_impl.cpp:949
Definition: collection.h:97
AtomicInt64 _nextIdNum
Definition: mobile_record_store.h:208
bool updateWithDamagesSupported() const override
Definition: mobile_record_store.cpp:481
bool compactSupported() const override
does this RecordStore support the compact operation?
Definition: mobile_record_store.h:96
void _initDataSizeIfNeeded_inlock(OperationContext *opCtx) const
Fetches the data size from the database.
Definition: mobile_record_store.cpp:226
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:278
stdx::mutex _numRecsMutex
Definition: mobile_record_store.h:228
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:485
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:766
bool _isNumRecsInitialized
Definition: mobile_record_store.h:229
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:134