summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/devnull/devnull_kv_engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/storage/devnull/devnull_kv_engine.cpp')
-rw-r--r--src/mongo/db/storage/devnull/devnull_kv_engine.cpp384
1 files changed, 204 insertions, 180 deletions
diff --git a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp
index 1d1d039b7a6..25ebf6a5de6 100644
--- a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp
+++ b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp
@@ -38,192 +38,216 @@
namespace mongo {
- class EmptyRecordCursor final : public RecordCursor {
- public:
- boost::optional<Record> next() final { return {}; }
- boost::optional<Record> seekExact(const RecordId& id) final { return {}; }
- void savePositioned() final {}
- bool restore(OperationContext* txn) final { return true; }
- };
-
- class DevNullRecordStore : public RecordStore {
- public:
- DevNullRecordStore( StringData ns, const CollectionOptions& options )
- : RecordStore( ns ), _options( options ) {
- _numInserts = 0;
- _dummy = BSON( "_id" << 1 );
- }
-
- virtual const char* name() const { return "devnull"; }
-
- virtual void setCappedDeleteCallback(CappedDocumentDeleteCallback*){}
-
- virtual long long dataSize( OperationContext* txn ) const { return 0; }
-
- virtual long long numRecords( OperationContext* txn ) const { return 0; }
-
- virtual bool isCapped() const { return _options.capped; }
-
- virtual int64_t storageSize( OperationContext* txn,
- BSONObjBuilder* extraInfo = NULL,
- int infoLevel = 0 ) const {
- return 0;
- }
-
- virtual RecordData dataFor( OperationContext* txn, const RecordId& loc) const {
- return RecordData( _dummy.objdata(), _dummy.objsize() );
- }
-
- virtual bool findRecord( OperationContext* txn, const RecordId& loc, RecordData* rd ) const {
- return false;
- }
-
- virtual void deleteRecord( OperationContext* txn, const RecordId& dl ) {}
-
- virtual StatusWith<RecordId> insertRecord( OperationContext* txn,
- const char* data,
- int len,
- bool enforceQuota ) {
- _numInserts++;
- return StatusWith<RecordId>( RecordId( 6, 4 ) );
- }
-
- virtual StatusWith<RecordId> insertRecord( OperationContext* txn,
- const DocWriter* doc,
- bool enforceQuota ) {
- _numInserts++;
- return StatusWith<RecordId>( RecordId( 6, 4 ) );
- }
-
- virtual StatusWith<RecordId> updateRecord( OperationContext* txn,
- const RecordId& oldLocation,
- const char* data,
- int len,
- bool enforceQuota,
- UpdateNotifier* notifier ) {
- return StatusWith<RecordId>( oldLocation );
- }
-
- virtual bool updateWithDamagesSupported() const {
- return false;
- }
-
- virtual Status updateWithDamages( OperationContext* txn,
- const RecordId& loc,
- const RecordData& oldRec,
- const char* damageSource,
- const mutablebson::DamageVector& damages ) {
- invariant(false);
- }
-
-
- std::unique_ptr<RecordCursor> getCursor(OperationContext* txn, bool forward) const final {
- return stdx::make_unique<EmptyRecordCursor>();
- }
-
- virtual Status truncate( OperationContext* txn ) { return Status::OK(); }
-
- virtual void temp_cappedTruncateAfter(OperationContext* txn,
- RecordId end,
- bool inclusive) { }
-
- virtual Status validate( OperationContext* txn,
- bool full, bool scanData,
- ValidateAdaptor* adaptor,
- ValidateResults* results, BSONObjBuilder* output ) {
- return Status::OK();
- }
-
- virtual void appendCustomStats( OperationContext* txn,
- BSONObjBuilder* result,
- double scale ) const {
- result->appendNumber( "numInserts", _numInserts );
- }
-
- virtual Status touch( OperationContext* txn, BSONObjBuilder* output ) const {
- return Status::OK();
- }
-
- virtual void updateStatsAfterRepair(OperationContext* txn,
- long long numRecords,
- long long dataSize) {
- }
-
- private:
- CollectionOptions _options;
- long long _numInserts;
- BSONObj _dummy;
- };
-
- class DevNullSortedDataBuilderInterface : public SortedDataBuilderInterface {
- MONGO_DISALLOW_COPYING(DevNullSortedDataBuilderInterface);
-
- public:
- DevNullSortedDataBuilderInterface() { }
-
- virtual Status addKey(const BSONObj& key, const RecordId& loc) {
- return Status::OK();
- }
- };
-
- class DevNullSortedDataInterface : public SortedDataInterface {
- public:
- virtual ~DevNullSortedDataInterface() { }
-
- virtual SortedDataBuilderInterface* getBulkBuilder(OperationContext* txn,
- bool dupsAllowed) {
- return new DevNullSortedDataBuilderInterface();
- }
-
- virtual Status insert(OperationContext* txn,
- const BSONObj& key,
- const RecordId& loc,
- bool dupsAllowed) { return Status::OK(); }
-
- virtual void unindex(OperationContext* txn,
- const BSONObj& key,
- const RecordId& loc,
- bool dupsAllowed) { }
-
- virtual Status dupKeyCheck(OperationContext* txn,
- const BSONObj& key,
- const RecordId& loc) { return Status::OK(); }
-
- virtual void fullValidate(OperationContext* txn, bool full, long long* numKeysOut,
- BSONObjBuilder* output) const { }
-
- virtual bool appendCustomStats(OperationContext* txn, BSONObjBuilder* output, double scale)
- const {
- return false;
- }
-
- virtual long long getSpaceUsedBytes( OperationContext* txn ) const { return 0; }
-
- virtual bool isEmpty(OperationContext* txn) { return true; }
+class EmptyRecordCursor final : public RecordCursor {
+public:
+ boost::optional<Record> next() final {
+ return {};
+ }
+ boost::optional<Record> seekExact(const RecordId& id) final {
+ return {};
+ }
+ void savePositioned() final {}
+ bool restore(OperationContext* txn) final {
+ return true;
+ }
+};
+
+class DevNullRecordStore : public RecordStore {
+public:
+ DevNullRecordStore(StringData ns, const CollectionOptions& options)
+ : RecordStore(ns), _options(options) {
+ _numInserts = 0;
+ _dummy = BSON("_id" << 1);
+ }
- virtual std::unique_ptr<SortedDataInterface::Cursor> newCursor(OperationContext* txn,
- bool isForward) const {
- return {};
- }
+ virtual const char* name() const {
+ return "devnull";
+ }
- virtual Status initAsEmpty(OperationContext* txn) { return Status::OK(); }
- };
+ virtual void setCappedDeleteCallback(CappedDocumentDeleteCallback*) {}
+
+ virtual long long dataSize(OperationContext* txn) const {
+ return 0;
+ }
+
+ virtual long long numRecords(OperationContext* txn) const {
+ return 0;
+ }
+
+ virtual bool isCapped() const {
+ return _options.capped;
+ }
+
+ virtual int64_t storageSize(OperationContext* txn,
+ BSONObjBuilder* extraInfo = NULL,
+ int infoLevel = 0) const {
+ return 0;
+ }
+
+ virtual RecordData dataFor(OperationContext* txn, const RecordId& loc) const {
+ return RecordData(_dummy.objdata(), _dummy.objsize());
+ }
+
+ virtual bool findRecord(OperationContext* txn, const RecordId& loc, RecordData* rd) const {
+ return false;
+ }
+
+ virtual void deleteRecord(OperationContext* txn, const RecordId& dl) {}
+
+ virtual StatusWith<RecordId> insertRecord(OperationContext* txn,
+ const char* data,
+ int len,
+ bool enforceQuota) {
+ _numInserts++;
+ return StatusWith<RecordId>(RecordId(6, 4));
+ }
+
+ virtual StatusWith<RecordId> insertRecord(OperationContext* txn,
+ const DocWriter* doc,
+ bool enforceQuota) {
+ _numInserts++;
+ return StatusWith<RecordId>(RecordId(6, 4));
+ }
+
+ virtual StatusWith<RecordId> updateRecord(OperationContext* txn,
+ const RecordId& oldLocation,
+ const char* data,
+ int len,
+ bool enforceQuota,
+ UpdateNotifier* notifier) {
+ return StatusWith<RecordId>(oldLocation);
+ }
+
+ virtual bool updateWithDamagesSupported() const {
+ return false;
+ }
+
+ virtual Status updateWithDamages(OperationContext* txn,
+ const RecordId& loc,
+ const RecordData& oldRec,
+ const char* damageSource,
+ const mutablebson::DamageVector& damages) {
+ invariant(false);
+ }
+
+
+ std::unique_ptr<RecordCursor> getCursor(OperationContext* txn, bool forward) const final {
+ return stdx::make_unique<EmptyRecordCursor>();
+ }
+
+ virtual Status truncate(OperationContext* txn) {
+ return Status::OK();
+ }
+ virtual void temp_cappedTruncateAfter(OperationContext* txn, RecordId end, bool inclusive) {}
- RecordStore* DevNullKVEngine::getRecordStore( OperationContext* opCtx,
- StringData ns,
- StringData ident,
- const CollectionOptions& options ) {
- if ( ident == "_mdb_catalog" ) {
- return new InMemoryRecordStore( ns, &_catalogInfo );
- }
- return new DevNullRecordStore( ns, options );
+ virtual Status validate(OperationContext* txn,
+ bool full,
+ bool scanData,
+ ValidateAdaptor* adaptor,
+ ValidateResults* results,
+ BSONObjBuilder* output) {
+ return Status::OK();
}
- SortedDataInterface* DevNullKVEngine::getSortedDataInterface( OperationContext* opCtx,
- StringData ident,
- const IndexDescriptor* desc ) {
- return new DevNullSortedDataInterface();
+ virtual void appendCustomStats(OperationContext* txn,
+ BSONObjBuilder* result,
+ double scale) const {
+ result->appendNumber("numInserts", _numInserts);
}
+ virtual Status touch(OperationContext* txn, BSONObjBuilder* output) const {
+ return Status::OK();
+ }
+
+ virtual void updateStatsAfterRepair(OperationContext* txn,
+ long long numRecords,
+ long long dataSize) {}
+
+private:
+ CollectionOptions _options;
+ long long _numInserts;
+ BSONObj _dummy;
+};
+
+class DevNullSortedDataBuilderInterface : public SortedDataBuilderInterface {
+ MONGO_DISALLOW_COPYING(DevNullSortedDataBuilderInterface);
+
+public:
+ DevNullSortedDataBuilderInterface() {}
+
+ virtual Status addKey(const BSONObj& key, const RecordId& loc) {
+ return Status::OK();
+ }
+};
+
+class DevNullSortedDataInterface : public SortedDataInterface {
+public:
+ virtual ~DevNullSortedDataInterface() {}
+
+ virtual SortedDataBuilderInterface* getBulkBuilder(OperationContext* txn, bool dupsAllowed) {
+ return new DevNullSortedDataBuilderInterface();
+ }
+
+ virtual Status insert(OperationContext* txn,
+ const BSONObj& key,
+ const RecordId& loc,
+ bool dupsAllowed) {
+ return Status::OK();
+ }
+
+ virtual void unindex(OperationContext* txn,
+ const BSONObj& key,
+ const RecordId& loc,
+ bool dupsAllowed) {}
+
+ virtual Status dupKeyCheck(OperationContext* txn, const BSONObj& key, const RecordId& loc) {
+ return Status::OK();
+ }
+
+ virtual void fullValidate(OperationContext* txn,
+ bool full,
+ long long* numKeysOut,
+ BSONObjBuilder* output) const {}
+
+ virtual bool appendCustomStats(OperationContext* txn,
+ BSONObjBuilder* output,
+ double scale) const {
+ return false;
+ }
+
+ virtual long long getSpaceUsedBytes(OperationContext* txn) const {
+ return 0;
+ }
+
+ virtual bool isEmpty(OperationContext* txn) {
+ return true;
+ }
+
+ virtual std::unique_ptr<SortedDataInterface::Cursor> newCursor(OperationContext* txn,
+ bool isForward) const {
+ return {};
+ }
+
+ virtual Status initAsEmpty(OperationContext* txn) {
+ return Status::OK();
+ }
+};
+
+
+RecordStore* DevNullKVEngine::getRecordStore(OperationContext* opCtx,
+ StringData ns,
+ StringData ident,
+ const CollectionOptions& options) {
+ if (ident == "_mdb_catalog") {
+ return new InMemoryRecordStore(ns, &_catalogInfo);
+ }
+ return new DevNullRecordStore(ns, options);
+}
+
+SortedDataInterface* DevNullKVEngine::getSortedDataInterface(OperationContext* opCtx,
+ StringData ident,
+ const IndexDescriptor* desc) {
+ return new DevNullSortedDataInterface();
+}
}