diff options
Diffstat (limited to 'src/mongo/db')
20 files changed, 284 insertions, 278 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript index b495f7ede6a..b73a5d92218 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -719,7 +719,7 @@ serveronlyLibdeps = [ "stats/counters", "stats/top", "storage/devnull/storage_devnull", - "storage/in_memory/storage_in_memory", + "storage/ephemeral_for_test/storage_ephemeral_for_test", "storage/mmap_v1/mmap", "storage/mmap_v1/storage_mmapv1", "storage/storage_engine_lock_file", diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp index 203ebe08934..4296f9d62e7 100644 --- a/src/mongo/db/repl/rs_rollback_test.cpp +++ b/src/mongo/db/repl/rs_rollback_test.cpp @@ -142,7 +142,7 @@ void RSRollbackTest::setUp() { unittest::TempDir tempDir("rs_rollback_test"); mongo::storageGlobalParams.dbpath = tempDir.path(); mongo::storageGlobalParams.dbpath = tempDir.path(); - mongo::storageGlobalParams.engine = "inMemoryExperiment"; + mongo::storageGlobalParams.engine = "ephemeralForTest"; mongo::storageGlobalParams.engineSetByUser = true; serviceContext->initializeGlobalStorageEngine(); } diff --git a/src/mongo/db/storage/SConscript b/src/mongo/db/storage/SConscript index 882bfc8dd30..d1470c8c04e 100644 --- a/src/mongo/db/storage/SConscript +++ b/src/mongo/db/storage/SConscript @@ -3,7 +3,7 @@ Import("env") env.SConscript( dirs=[ 'devnull', - 'in_memory', + 'ephemeral_for_test', 'kv', 'mmap_v1', 'wiredtiger', diff --git a/src/mongo/db/storage/devnull/SConscript b/src/mongo/db/storage/devnull/SConscript index e3355801c3c..22f82359129 100644 --- a/src/mongo/db/storage/devnull/SConscript +++ b/src/mongo/db/storage/devnull/SConscript @@ -6,7 +6,7 @@ env.Library( 'devnull_kv_engine.cpp', ], LIBDEPS=[ - '$BUILD_DIR/mongo/db/storage/in_memory/in_memory_record_store', + '$BUILD_DIR/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store', '$BUILD_DIR/mongo/db/storage/kv/kv_storage_engine', ], ) diff --git a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp index 272cb344910..9c82309d5c9 100644 --- a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp +++ b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp @@ -31,7 +31,7 @@ #include "mongo/db/storage/devnull/devnull_kv_engine.h" #include "mongo/base/disallow_copying.h" -#include "mongo/db/storage/in_memory/in_memory_record_store.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h" #include "mongo/db/storage/record_store.h" #include "mongo/db/storage/sorted_data_interface.h" #include "mongo/stdx/memory.h" @@ -243,7 +243,7 @@ RecordStore* DevNullKVEngine::getRecordStore(OperationContext* opCtx, StringData ident, const CollectionOptions& options) { if (ident == "_mdb_catalog") { - return new InMemoryRecordStore(ns, &_catalogInfo); + return new EphemeralForTestRecordStore(ns, &_catalogInfo); } return new DevNullRecordStore(ns, options); } diff --git a/src/mongo/db/storage/in_memory/SConscript b/src/mongo/db/storage/ephemeral_for_test/SConscript index b077784f505..0b4c4729200 100644 --- a/src/mongo/db/storage/in_memory/SConscript +++ b/src/mongo/db/storage/ephemeral_for_test/SConscript @@ -1,9 +1,9 @@ Import("env") env.Library( - target= 'in_memory_record_store', + target= 'ephemeral_for_test_record_store', source= [ - 'in_memory_record_store.cpp' + 'ephemeral_for_test_record_store.cpp' ], LIBDEPS= [ '$BUILD_DIR/mongo/base', @@ -13,14 +13,14 @@ env.Library( ) env.Library( - target= 'storage_in_memory_core', + target= 'storage_ephemeral_for_test_core', source= [ - 'in_memory_btree_impl.cpp', - 'in_memory_engine.cpp', - 'in_memory_recovery_unit.cpp', + 'ephemeral_for_test_btree_impl.cpp', + 'ephemeral_for_test_engine.cpp', + 'ephemeral_for_test_recovery_unit.cpp', ], LIBDEPS= [ - 'in_memory_record_store', + 'ephemeral_for_test_record_store', '$BUILD_DIR/mongo/base', '$BUILD_DIR/mongo/db/namespace_string', '$BUILD_DIR/mongo/db/catalog/collection_options', @@ -31,42 +31,42 @@ env.Library( ) env.Library( - target= 'storage_in_memory', + target= 'storage_ephemeral_for_test', source= [ - 'in_memory_init.cpp', + 'ephemeral_for_test_init.cpp', ], LIBDEPS= [ - 'storage_in_memory_core', + 'storage_ephemeral_for_test_core', '$BUILD_DIR/mongo/db/storage/kv/kv_engine' ] ) env.CppUnitTest( - target='storage_in_memory_btree_test', - source=['in_memory_btree_impl_test.cpp' + target='storage_ephemeral_for_test_btree_test', + source=['ephemeral_for_test_btree_impl_test.cpp' ], LIBDEPS=[ - 'storage_in_memory_core', + 'storage_ephemeral_for_test_core', '$BUILD_DIR/mongo/db/storage/sorted_data_interface_test_harness' ] ) env.CppUnitTest( - target='storage_in_memory_record_store_test', - source=['in_memory_record_store_test.cpp' + target='storage_ephemeral_for_test_record_store_test', + source=['ephemeral_for_test_record_store_test.cpp' ], LIBDEPS=[ - 'storage_in_memory_core', + 'storage_ephemeral_for_test_core', '$BUILD_DIR/mongo/db/storage/record_store_test_harness' ] ) env.CppUnitTest( - target='storage_in_memory_engine_test', - source=['in_memory_engine_test.cpp', + target='storage_ephemeral_for_test_engine_test', + source=['ephemeral_for_test_engine_test.cpp', ], LIBDEPS=[ - 'storage_in_memory_core', + 'storage_ephemeral_for_test_core', '$BUILD_DIR/mongo/db/storage/kv/kv_engine_test_harness', ], ) diff --git a/src/mongo/db/storage/in_memory/in_memory_btree_impl.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp index 211a1165a47..0029b05374d 100644 --- a/src/mongo/db/storage/in_memory/in_memory_btree_impl.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.cpp @@ -1,4 +1,4 @@ -// in_memory_btree_impl.cpp +// ephemeral_for_test_btree_impl.cpp /** * Copyright (C) 2014 MongoDB Inc. @@ -30,13 +30,13 @@ #include "mongo/platform/basic.h" -#include "mongo/db/storage/in_memory/in_memory_btree_impl.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h" #include <set> #include "mongo/db/catalog/index_catalog_entry.h" #include "mongo/db/storage/index_entry_comparison.h" -#include "mongo/db/storage/in_memory/in_memory_recovery_unit.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h" #include "mongo/stdx/memory.h" #include "mongo/util/mongoutils/str.h" @@ -89,9 +89,9 @@ bool isDup(const IndexSet& data, const BSONObj& key, RecordId loc) { return it->loc != loc; } -class InMemoryBtreeBuilderImpl : public SortedDataBuilderInterface { +class EphemeralForTestBtreeBuilderImpl : public SortedDataBuilderInterface { public: - InMemoryBtreeBuilderImpl(IndexSet* data, long long* currentKeySize, bool dupsAllowed) + EphemeralForTestBtreeBuilderImpl(IndexSet* data, long long* currentKeySize, bool dupsAllowed) : _data(data), _currentKeySize(currentKeySize), _dupsAllowed(dupsAllowed), @@ -136,14 +136,14 @@ private: IndexSet::const_iterator _last; // or (key, RecordId) ordering violations }; -class InMemoryBtreeImpl : public SortedDataInterface { +class EphemeralForTestBtreeImpl : public SortedDataInterface { public: - InMemoryBtreeImpl(IndexSet* data) : _data(data) { + EphemeralForTestBtreeImpl(IndexSet* data) : _data(data) { _currentKeySize = 0; } virtual SortedDataBuilderInterface* getBulkBuilder(OperationContext* txn, bool dupsAllowed) { - return new InMemoryBtreeBuilderImpl(_data, &_currentKeySize, dupsAllowed); + return new EphemeralForTestBtreeBuilderImpl(_data, &_currentKeySize, dupsAllowed); } virtual Status insert(OperationContext* txn, @@ -155,8 +155,8 @@ public: if (key.objsize() >= TempKeyMaxSize) { string msg = mongoutils::str::stream() - << "InMemoryBtree::insert: key too large to index, failing " << ' ' << key.objsize() - << ' ' << key; + << "EphemeralForTestBtree::insert: key too large to index, failing " << ' ' + << key.objsize() << ' ' << key; return Status(ErrorCodes::KeyTooLong, msg); } @@ -484,13 +484,13 @@ private: // IndexCatalogEntry argument taken by non-const pointer for consistency with other Btree // factories. We don't actually modify it. -SortedDataInterface* getInMemoryBtreeImpl(const Ordering& ordering, - std::shared_ptr<void>* dataInOut) { +SortedDataInterface* getEphemeralForTestBtreeImpl(const Ordering& ordering, + std::shared_ptr<void>* dataInOut) { invariant(dataInOut); if (!*dataInOut) { *dataInOut = std::make_shared<IndexSet>(IndexEntryComparison(ordering)); } - return new InMemoryBtreeImpl(static_cast<IndexSet*>(dataInOut->get())); + return new EphemeralForTestBtreeImpl(static_cast<IndexSet*>(dataInOut->get())); } } // namespace mongo diff --git a/src/mongo/db/storage/in_memory/in_memory_btree_impl.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h index ed330d40d10..6e19eb4c945 100644 --- a/src/mongo/db/storage/in_memory/in_memory_btree_impl.h +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h @@ -1,4 +1,4 @@ -// in_memory_btree_impl.h +// ephemeral_for_test_btree_impl.h /** * Copyright (C) 2014 MongoDB Inc. @@ -41,7 +41,7 @@ class IndexCatalogEntry; * Caller takes ownership. * All permanent data will be stored and fetch from dataInOut. */ -SortedDataInterface* getInMemoryBtreeImpl(const Ordering& ordering, - std::shared_ptr<void>* dataInOut); +SortedDataInterface* getEphemeralForTestBtreeImpl(const Ordering& ordering, + std::shared_ptr<void>* dataInOut); } // namespace mongo diff --git a/src/mongo/db/storage/in_memory/in_memory_btree_impl_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp index 719e187d548..f5d5a8dca3c 100644 --- a/src/mongo/db/storage/in_memory/in_memory_btree_impl_test.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl_test.cpp @@ -1,4 +1,4 @@ -// in_memory_btree_impl_test.cpp +// ephemeral_for_test_btree_impl_test.cpp /** * Copyright (C) 2014 MongoDB Inc. @@ -28,34 +28,34 @@ * it in the license file. */ -#include "mongo/db/storage/in_memory/in_memory_btree_impl.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h" -#include "mongo/db/storage/in_memory/in_memory_recovery_unit.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h" #include "mongo/db/storage/sorted_data_interface_test_harness.h" #include "mongo/stdx/memory.h" #include "mongo/unittest/unittest.h" namespace mongo { -class InMemoryHarnessHelper final : public HarnessHelper { +class EphemeralForTestHarnessHelper final : public HarnessHelper { public: - InMemoryHarnessHelper() : _order(Ordering::make(BSONObj())) {} + EphemeralForTestHarnessHelper() : _order(Ordering::make(BSONObj())) {} std::unique_ptr<SortedDataInterface> newSortedDataInterface(bool unique) final { - return std::unique_ptr<SortedDataInterface>(getInMemoryBtreeImpl(_order, &_data)); + return std::unique_ptr<SortedDataInterface>(getEphemeralForTestBtreeImpl(_order, &_data)); } std::unique_ptr<RecoveryUnit> newRecoveryUnit() final { - return stdx::make_unique<InMemoryRecoveryUnit>(); + return stdx::make_unique<EphemeralForTestRecoveryUnit>(); } private: - std::shared_ptr<void> _data; // used by InMemoryBtreeImpl + std::shared_ptr<void> _data; // used by EphemeralForTestBtreeImpl Ordering _order; }; std::unique_ptr<HarnessHelper> newHarnessHelper() { - return stdx::make_unique<InMemoryHarnessHelper>(); + return stdx::make_unique<EphemeralForTestHarnessHelper>(); } } diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp new file mode 100644 index 00000000000..dad8c56e408 --- /dev/null +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp @@ -0,0 +1,102 @@ +// ephemeral_for_test_engine.cpp + +/** +* Copyright (C) 2014 MongoDB Inc. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License, version 3, +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +* As a special exception, the copyright holders give permission to link the +* code of portions of this program with the OpenSSL library under certain +* conditions as described in each individual source file and distribute +* linked combinations including the program with the OpenSSL library. You +* must comply with the GNU Affero General Public License in all respects for +* all of the code used other than as permitted herein. If you modify file(s) +* with this exception, you may extend this exception to your version of the +* file(s), but you are not obligated to do so. If you do not wish to do so, +* delete this exception statement from your version. If you delete this +* exception statement from all source files in the program, then also delete +* it in the license file. +*/ + +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h" + +#include "mongo/db/index/index_descriptor.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h" + +namespace mongo { + +RecoveryUnit* EphemeralForTestEngine::newRecoveryUnit() { + return new EphemeralForTestRecoveryUnit(); +} + +Status EphemeralForTestEngine::createRecordStore(OperationContext* opCtx, + StringData ns, + StringData ident, + const CollectionOptions& options) { + // All work done in getRecordStore + return Status::OK(); +} + +RecordStore* EphemeralForTestEngine::getRecordStore(OperationContext* opCtx, + StringData ns, + StringData ident, + const CollectionOptions& options) { + stdx::lock_guard<stdx::mutex> lk(_mutex); + if (options.capped) { + return new EphemeralForTestRecordStore(ns, + &_dataMap[ident], + true, + options.cappedSize ? options.cappedSize : 4096, + options.cappedMaxDocs ? options.cappedMaxDocs : -1); + } else { + return new EphemeralForTestRecordStore(ns, &_dataMap[ident]); + } +} + +Status EphemeralForTestEngine::createSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc) { + // All work done in getSortedDataInterface + return Status::OK(); +} + +SortedDataInterface* EphemeralForTestEngine::getSortedDataInterface(OperationContext* opCtx, + StringData ident, + const IndexDescriptor* desc) { + stdx::lock_guard<stdx::mutex> lk(_mutex); + return getEphemeralForTestBtreeImpl(Ordering::make(desc->keyPattern()), &_dataMap[ident]); +} + +Status EphemeralForTestEngine::dropIdent(OperationContext* opCtx, StringData ident) { + stdx::lock_guard<stdx::mutex> lk(_mutex); + _dataMap.erase(ident); + return Status::OK(); +} + +int64_t EphemeralForTestEngine::getIdentSize(OperationContext* opCtx, StringData ident) { + return 1; +} + +std::vector<std::string> EphemeralForTestEngine::getAllIdents(OperationContext* opCtx) const { + std::vector<std::string> all; + { + stdx::lock_guard<stdx::mutex> lk(_mutex); + for (DataMap::const_iterator it = _dataMap.begin(); it != _dataMap.end(); ++it) { + all.push_back(it->first); + } + } + return all; +} +} diff --git a/src/mongo/db/storage/in_memory/in_memory_engine.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h index 55f9c463055..9ae1ddff9d8 100644 --- a/src/mongo/db/storage/in_memory/in_memory_engine.h +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h @@ -1,4 +1,4 @@ -// in_memory_engine.h +// ephemeral_for_test_engine.h /** * Copyright (C) 2014 MongoDB Inc. @@ -36,7 +36,7 @@ namespace mongo { -class InMemoryEngine : public KVEngine { +class EphemeralForTestEngine : public KVEngine { public: virtual RecoveryUnit* newRecoveryUnit(); diff --git a/src/mongo/db/storage/in_memory/in_memory_engine_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine_test.cpp index 1427810637f..def552757b1 100644 --- a/src/mongo/db/storage/in_memory/in_memory_engine_test.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine_test.cpp @@ -1,4 +1,4 @@ -// in_memory_engine_test.cpp +// ephemeral_for_test_engine_test.cpp /** * Copyright (C) 2014 MongoDB Inc. @@ -28,14 +28,14 @@ * it in the license file. */ -#include "mongo/db/storage/in_memory/in_memory_engine.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h" #include "mongo/db/storage/kv/kv_engine_test_harness.h" namespace mongo { -class InMemoryKVHarnessHelper : public KVHarnessHelper { +class EphemeralForTestKVHarnessHelper : public KVHarnessHelper { public: - InMemoryKVHarnessHelper() : _engine(new InMemoryEngine()) {} + EphemeralForTestKVHarnessHelper() : _engine(new EphemeralForTestEngine()) {} virtual KVEngine* restartEngine() { // Intentionally not restarting since the in-memory storage engine @@ -48,10 +48,10 @@ public: } private: - std::unique_ptr<InMemoryEngine> _engine; + std::unique_ptr<EphemeralForTestEngine> _engine; }; KVHarnessHelper* KVHarnessHelper::create() { - return new InMemoryKVHarnessHelper(); + return new EphemeralForTestKVHarnessHelper(); } } diff --git a/src/mongo/db/storage/in_memory/in_memory_init.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_init.cpp index ab2ebb20a1f..5e66d5c18dc 100644 --- a/src/mongo/db/storage/in_memory/in_memory_init.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_init.cpp @@ -1,4 +1,4 @@ -// in_memory_init.cpp +// ephemeral_for_test_init.cpp /** * Copyright (C) 2014 MongoDB Inc. @@ -31,7 +31,7 @@ #include "mongo/base/init.h" #include "mongo/db/service_context.h" -#include "mongo/db/storage/in_memory/in_memory_engine.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h" #include "mongo/db/storage/kv/kv_storage_engine.h" #include "mongo/db/storage/storage_options.h" @@ -39,19 +39,19 @@ namespace mongo { namespace { -class InMemoryFactory : public StorageEngine::Factory { +class EphemeralForTestFactory : public StorageEngine::Factory { public: - virtual ~InMemoryFactory() {} + virtual ~EphemeralForTestFactory() {} virtual StorageEngine* create(const StorageGlobalParams& params, const StorageEngineLockFile& lockFile) const { KVStorageEngineOptions options; options.directoryPerDB = params.directoryperdb; options.forRepair = params.repair; - return new KVStorageEngine(new InMemoryEngine(), options); + return new KVStorageEngine(new EphemeralForTestEngine(), options); } virtual StringData getCanonicalName() const { - return "inMemoryExperiment"; + return "ephemeralForTest"; } virtual Status validateMetadata(const StorageEngineMetadata& metadata, @@ -66,9 +66,10 @@ public: } // namespace -MONGO_INITIALIZER_WITH_PREREQUISITES(InMemoryEngineInit, ("SetGlobalEnvironment")) +MONGO_INITIALIZER_WITH_PREREQUISITES(EphemeralForTestEngineInit, ("SetGlobalEnvironment")) (InitializerContext* context) { - getGlobalServiceContext()->registerStorageEngine("inMemoryExperiment", new InMemoryFactory()); + getGlobalServiceContext()->registerStorageEngine("ephemeralForTest", + new EphemeralForTestFactory()); return Status::OK(); } diff --git a/src/mongo/db/storage/in_memory/in_memory_record_store.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.cpp index 2b912cb1160..6f1c48663dd 100644 --- a/src/mongo/db/storage/in_memory/in_memory_record_store.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.cpp @@ -1,4 +1,4 @@ -// in_memory_record_store.cpp +// ephemeral_for_test_record_store.cpp /** * Copyright (C) 2014 MongoDB Inc. @@ -31,7 +31,7 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage -#include "mongo/db/storage/in_memory/in_memory_record_store.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h" #include "mongo/db/jsobj.h" @@ -48,7 +48,7 @@ namespace mongo { using std::shared_ptr; -class InMemoryRecordStore::InsertChange : public RecoveryUnit::Change { +class EphemeralForTestRecordStore::InsertChange : public RecoveryUnit::Change { public: InsertChange(Data* data, RecordId loc) : _data(data), _loc(loc) {} virtual void commit() {} @@ -66,9 +66,9 @@ private: }; // Works for both removes and updates -class InMemoryRecordStore::RemoveChange : public RecoveryUnit::Change { +class EphemeralForTestRecordStore::RemoveChange : public RecoveryUnit::Change { public: - RemoveChange(Data* data, RecordId loc, const InMemoryRecord& rec) + RemoveChange(Data* data, RecordId loc, const EphemeralForTestRecord& rec) : _data(data), _loc(loc), _rec(rec) {} virtual void commit() {} @@ -85,10 +85,10 @@ public: private: Data* const _data; const RecordId _loc; - const InMemoryRecord _rec; + const EphemeralForTestRecord _rec; }; -class InMemoryRecordStore::TruncateChange : public RecoveryUnit::Change { +class EphemeralForTestRecordStore::TruncateChange : public RecoveryUnit::Change { public: TruncateChange(Data* data) : _data(data), _dataSize(0) { using std::swap; @@ -109,9 +109,9 @@ private: Records _records; }; -class InMemoryRecordStore::Cursor final : public SeekableRecordCursor { +class EphemeralForTestRecordStore::Cursor final : public SeekableRecordCursor { public: - Cursor(OperationContext* txn, const InMemoryRecordStore& rs) + Cursor(OperationContext* txn, const EphemeralForTestRecordStore& rs) : _records(rs._data->records), _isCapped(rs.isCapped()) {} boost::optional<Record> next() final { @@ -168,13 +168,13 @@ private: bool _lastMoveWasRestore = false; RecordId _savedId; // Location to restore() to. Null means EOF. - const InMemoryRecordStore::Records& _records; + const EphemeralForTestRecordStore::Records& _records; const bool _isCapped; }; -class InMemoryRecordStore::ReverseCursor final : public SeekableRecordCursor { +class EphemeralForTestRecordStore::ReverseCursor final : public SeekableRecordCursor { public: - ReverseCursor(OperationContext* txn, const InMemoryRecordStore& rs) + ReverseCursor(OperationContext* txn, const EphemeralForTestRecordStore& rs) : _records(rs._data->records), _isCapped(rs.isCapped()) {} boost::optional<Record> next() final { @@ -243,7 +243,7 @@ private: bool _needFirstSeek = true; bool _lastMoveWasRestore = false; RecordId _savedId; // Location to restore() to. Null means EOF. - const InMemoryRecordStore::Records& _records; + const EphemeralForTestRecordStore::Records& _records; const bool _isCapped; }; @@ -252,12 +252,12 @@ private: // RecordStore // -InMemoryRecordStore::InMemoryRecordStore(StringData ns, - std::shared_ptr<void>* dataInOut, - bool isCapped, - int64_t cappedMaxSize, - int64_t cappedMaxDocs, - CappedCallback* cappedCallback) +EphemeralForTestRecordStore::EphemeralForTestRecordStore(StringData ns, + std::shared_ptr<void>* dataInOut, + bool isCapped, + int64_t cappedMaxSize, + int64_t cappedMaxDocs, + CappedCallback* cappedCallback) : RecordStore(ns), _isCapped(isCapped), _cappedMaxSize(cappedMaxSize), @@ -278,36 +278,39 @@ InMemoryRecordStore::InMemoryRecordStore(StringData ns, } } -const char* InMemoryRecordStore::name() const { - return "InMemory"; +const char* EphemeralForTestRecordStore::name() const { + return "EphemeralForTest"; } -RecordData InMemoryRecordStore::dataFor(OperationContext* txn, const RecordId& loc) const { +RecordData EphemeralForTestRecordStore::dataFor(OperationContext* txn, const RecordId& loc) const { return recordFor(loc)->toRecordData(); } -const InMemoryRecordStore::InMemoryRecord* InMemoryRecordStore::recordFor( +const EphemeralForTestRecordStore::EphemeralForTestRecord* EphemeralForTestRecordStore::recordFor( const RecordId& loc) const { Records::const_iterator it = _data->records.find(loc); if (it == _data->records.end()) { - error() << "InMemoryRecordStore::recordFor cannot find record for " << ns() << ":" << loc; + error() << "EphemeralForTestRecordStore::recordFor cannot find record for " << ns() << ":" + << loc; } invariant(it != _data->records.end()); return &it->second; } -InMemoryRecordStore::InMemoryRecord* InMemoryRecordStore::recordFor(const RecordId& loc) { +EphemeralForTestRecordStore::EphemeralForTestRecord* EphemeralForTestRecordStore::recordFor( + const RecordId& loc) { Records::iterator it = _data->records.find(loc); if (it == _data->records.end()) { - error() << "InMemoryRecordStore::recordFor cannot find record for " << ns() << ":" << loc; + error() << "EphemeralForTestRecordStore::recordFor cannot find record for " << ns() << ":" + << loc; } invariant(it != _data->records.end()); return &it->second; } -bool InMemoryRecordStore::findRecord(OperationContext* txn, - const RecordId& loc, - RecordData* rd) const { +bool EphemeralForTestRecordStore::findRecord(OperationContext* txn, + const RecordId& loc, + RecordData* rd) const { Records::const_iterator it = _data->records.find(loc); if (it == _data->records.end()) { return false; @@ -316,14 +319,14 @@ bool InMemoryRecordStore::findRecord(OperationContext* txn, return true; } -void InMemoryRecordStore::deleteRecord(OperationContext* txn, const RecordId& loc) { - InMemoryRecord* rec = recordFor(loc); +void EphemeralForTestRecordStore::deleteRecord(OperationContext* txn, const RecordId& loc) { + EphemeralForTestRecord* rec = recordFor(loc); txn->recoveryUnit()->registerChange(new RemoveChange(_data, loc, *rec)); _data->dataSize -= rec->size; invariant(_data->records.erase(loc) == 1); } -bool InMemoryRecordStore::cappedAndNeedDelete(OperationContext* txn) const { +bool EphemeralForTestRecordStore::cappedAndNeedDelete(OperationContext* txn) const { if (!_isCapped) return false; @@ -336,7 +339,7 @@ bool InMemoryRecordStore::cappedAndNeedDelete(OperationContext* txn) const { return false; } -void InMemoryRecordStore::cappedDeleteAsNeeded(OperationContext* txn) { +void EphemeralForTestRecordStore::cappedDeleteAsNeeded(OperationContext* txn) { while (cappedAndNeedDelete(txn)) { invariant(!_data->records.empty()); @@ -351,8 +354,8 @@ void InMemoryRecordStore::cappedDeleteAsNeeded(OperationContext* txn) { } } -StatusWith<RecordId> InMemoryRecordStore::extractAndCheckLocForOplog(const char* data, - int len) const { +StatusWith<RecordId> EphemeralForTestRecordStore::extractAndCheckLocForOplog(const char* data, + int len) const { StatusWith<RecordId> status = oploghack::extractKey(data, len); if (!status.isOK()) return status; @@ -363,17 +366,17 @@ StatusWith<RecordId> InMemoryRecordStore::extractAndCheckLocForOplog(const char* return status; } -StatusWith<RecordId> InMemoryRecordStore::insertRecord(OperationContext* txn, - const char* data, - int len, - bool enforceQuota) { +StatusWith<RecordId> EphemeralForTestRecordStore::insertRecord(OperationContext* txn, + const char* data, + int len, + bool enforceQuota) { if (_isCapped && len > _cappedMaxSize) { // We use dataSize for capped rollover and we don't want to delete everything if we know // this won't fit. return StatusWith<RecordId>(ErrorCodes::BadValue, "object to insert exceeds cappedMaxSize"); } - InMemoryRecord rec(len); + EphemeralForTestRecord rec(len); memcpy(rec.data.get(), data, len); RecordId loc; @@ -395,9 +398,9 @@ StatusWith<RecordId> InMemoryRecordStore::insertRecord(OperationContext* txn, return StatusWith<RecordId>(loc); } -StatusWith<RecordId> InMemoryRecordStore::insertRecord(OperationContext* txn, - const DocWriter* doc, - bool enforceQuota) { +StatusWith<RecordId> EphemeralForTestRecordStore::insertRecord(OperationContext* txn, + const DocWriter* doc, + bool enforceQuota) { const int len = doc->documentSize(); if (_isCapped && len > _cappedMaxSize) { // We use dataSize for capped rollover and we don't want to delete everything if we know @@ -405,7 +408,7 @@ StatusWith<RecordId> InMemoryRecordStore::insertRecord(OperationContext* txn, return StatusWith<RecordId>(ErrorCodes::BadValue, "object to insert exceeds cappedMaxSize"); } - InMemoryRecord rec(len); + EphemeralForTestRecord rec(len); doc->writeDocument(rec.data.get()); RecordId loc; @@ -427,13 +430,13 @@ StatusWith<RecordId> InMemoryRecordStore::insertRecord(OperationContext* txn, return StatusWith<RecordId>(loc); } -StatusWith<RecordId> InMemoryRecordStore::updateRecord(OperationContext* txn, - const RecordId& loc, - const char* data, - int len, - bool enforceQuota, - UpdateNotifier* notifier) { - InMemoryRecord* oldRecord = recordFor(loc); +StatusWith<RecordId> EphemeralForTestRecordStore::updateRecord(OperationContext* txn, + const RecordId& loc, + const char* data, + int len, + bool enforceQuota, + UpdateNotifier* notifier) { + EphemeralForTestRecord* oldRecord = recordFor(loc); int oldLen = oldRecord->size; // Documents in capped collections cannot change size. We check that above the storage layer. @@ -448,7 +451,7 @@ StatusWith<RecordId> InMemoryRecordStore::updateRecord(OperationContext* txn, } } - InMemoryRecord newRecord(len); + EphemeralForTestRecord newRecord(len); memcpy(newRecord.data.get(), data, len); txn->recoveryUnit()->registerChange(new RemoveChange(_data, loc, *oldRecord)); @@ -460,20 +463,20 @@ StatusWith<RecordId> InMemoryRecordStore::updateRecord(OperationContext* txn, return StatusWith<RecordId>(loc); } -bool InMemoryRecordStore::updateWithDamagesSupported() const { +bool EphemeralForTestRecordStore::updateWithDamagesSupported() const { return true; } -StatusWith<RecordData> InMemoryRecordStore::updateWithDamages( +StatusWith<RecordData> EphemeralForTestRecordStore::updateWithDamages( OperationContext* txn, const RecordId& loc, const RecordData& oldRec, const char* damageSource, const mutablebson::DamageVector& damages) { - InMemoryRecord* oldRecord = recordFor(loc); + EphemeralForTestRecord* oldRecord = recordFor(loc); const int len = oldRecord->size; - InMemoryRecord newRecord(len); + EphemeralForTestRecord newRecord(len); memcpy(newRecord.data.get(), oldRecord->data.get(), len); txn->recoveryUnit()->registerChange(new RemoveChange(_data, loc, *oldRecord)); @@ -495,23 +498,23 @@ StatusWith<RecordData> InMemoryRecordStore::updateWithDamages( return newRecord.toRecordData(); } -std::unique_ptr<SeekableRecordCursor> InMemoryRecordStore::getCursor(OperationContext* txn, - bool forward) const { +std::unique_ptr<SeekableRecordCursor> EphemeralForTestRecordStore::getCursor(OperationContext* txn, + bool forward) const { if (forward) return stdx::make_unique<Cursor>(txn, *this); return stdx::make_unique<ReverseCursor>(txn, *this); } -Status InMemoryRecordStore::truncate(OperationContext* txn) { +Status EphemeralForTestRecordStore::truncate(OperationContext* txn) { // Unlike other changes, TruncateChange mutates _data on construction to perform the // truncate txn->recoveryUnit()->registerChange(new TruncateChange(_data)); return Status::OK(); } -void InMemoryRecordStore::temp_cappedTruncateAfter(OperationContext* txn, - RecordId end, - bool inclusive) { +void EphemeralForTestRecordStore::temp_cappedTruncateAfter(OperationContext* txn, + RecordId end, + bool inclusive) { Records::iterator it = inclusive ? _data->records.lower_bound(end) : _data->records.upper_bound(end); while (it != _data->records.end()) { @@ -521,17 +524,17 @@ void InMemoryRecordStore::temp_cappedTruncateAfter(OperationContext* txn, } } -Status InMemoryRecordStore::validate(OperationContext* txn, - bool full, - bool scanData, - ValidateAdaptor* adaptor, - ValidateResults* results, - BSONObjBuilder* output) { +Status EphemeralForTestRecordStore::validate(OperationContext* txn, + bool full, + bool scanData, + ValidateAdaptor* adaptor, + ValidateResults* results, + BSONObjBuilder* output) { results->valid = true; if (scanData && full) { for (Records::const_iterator it = _data->records.begin(); it != _data->records.end(); ++it) { - const InMemoryRecord& rec = it->second; + const EphemeralForTestRecord& rec = it->second; size_t dataSize; const Status status = adaptor->validate(rec.toRecordData(), &dataSize); if (!status.isOK()) { @@ -547,9 +550,9 @@ Status InMemoryRecordStore::validate(OperationContext* txn, return Status::OK(); } -void InMemoryRecordStore::appendCustomStats(OperationContext* txn, - BSONObjBuilder* result, - double scale) const { +void EphemeralForTestRecordStore::appendCustomStats(OperationContext* txn, + BSONObjBuilder* result, + double scale) const { result->appendBool("capped", _isCapped); if (_isCapped) { result->appendIntOrLL("max", _cappedMaxDocs); @@ -557,7 +560,7 @@ void InMemoryRecordStore::appendCustomStats(OperationContext* txn, } } -Status InMemoryRecordStore::touch(OperationContext* txn, BSONObjBuilder* output) const { +Status EphemeralForTestRecordStore::touch(OperationContext* txn, BSONObjBuilder* output) const { if (output) { output->append("numRanges", 1); output->append("millis", 0); @@ -565,26 +568,28 @@ Status InMemoryRecordStore::touch(OperationContext* txn, BSONObjBuilder* output) return Status::OK(); } -void InMemoryRecordStore::increaseStorageSize(OperationContext* txn, int size, bool enforceQuota) { +void EphemeralForTestRecordStore::increaseStorageSize(OperationContext* txn, + int size, + bool enforceQuota) { // unclear what this would mean for this class. For now, just error if called. invariant(!"increaseStorageSize not yet implemented"); } -int64_t InMemoryRecordStore::storageSize(OperationContext* txn, - BSONObjBuilder* extraInfo, - int infoLevel) const { +int64_t EphemeralForTestRecordStore::storageSize(OperationContext* txn, + BSONObjBuilder* extraInfo, + int infoLevel) const { // Note: not making use of extraInfo or infoLevel since we don't have extents - const int64_t recordOverhead = numRecords(txn) * sizeof(InMemoryRecord); + const int64_t recordOverhead = numRecords(txn) * sizeof(EphemeralForTestRecord); return _data->dataSize + recordOverhead; } -RecordId InMemoryRecordStore::allocateLoc() { +RecordId EphemeralForTestRecordStore::allocateLoc() { RecordId out = RecordId(_data->nextId++); invariant(out < RecordId::max()); return out; } -boost::optional<RecordId> InMemoryRecordStore::oplogStartHack( +boost::optional<RecordId> EphemeralForTestRecordStore::oplogStartHack( OperationContext* txn, const RecordId& startingPosition) const { if (!_data->isOplog) return boost::none; diff --git a/src/mongo/db/storage/in_memory/in_memory_record_store.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h index eba795b862f..324a30653eb 100644 --- a/src/mongo/db/storage/in_memory/in_memory_record_store.h +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h @@ -1,4 +1,4 @@ -// in_memory_record_store.h +// ephemeral_for_test_record_store.h /** * Copyright (C) 2014 MongoDB Inc. @@ -43,14 +43,14 @@ namespace mongo { * * @param cappedMaxSize - required if isCapped. limit uses dataSize() in this impl. */ -class InMemoryRecordStore : public RecordStore { +class EphemeralForTestRecordStore : public RecordStore { public: - explicit InMemoryRecordStore(StringData ns, - std::shared_ptr<void>* dataInOut, - bool isCapped = false, - int64_t cappedMaxSize = -1, - int64_t cappedMaxDocs = -1, - CappedCallback* cappedCallback = nullptr); + explicit EphemeralForTestRecordStore(StringData ns, + std::shared_ptr<void>* dataInOut, + bool isCapped = false, + int64_t cappedMaxSize = -1, + int64_t cappedMaxDocs = -1, + CappedCallback* cappedCallback = nullptr); virtual const char* name() const; @@ -129,9 +129,9 @@ public: } protected: - struct InMemoryRecord { - InMemoryRecord() : size(0) {} - InMemoryRecord(int size) : size(size), data(new char[size]) {} + struct EphemeralForTestRecord { + EphemeralForTestRecord() : size(0) {} + EphemeralForTestRecord(int size) : size(size), data(new char[size]) {} RecordData toRecordData() const { return RecordData(data.get(), size); @@ -141,15 +141,15 @@ protected: boost::shared_array<char> data; }; - virtual const InMemoryRecord* recordFor(const RecordId& loc) const; - virtual InMemoryRecord* recordFor(const RecordId& loc); + virtual const EphemeralForTestRecord* recordFor(const RecordId& loc) const; + virtual EphemeralForTestRecord* recordFor(const RecordId& loc); public: // // Not in RecordStore interface // - typedef std::map<RecordId, InMemoryRecord> Records; + typedef std::map<RecordId, EphemeralForTestRecord> Records; bool isCapped() const { return _isCapped; diff --git a/src/mongo/db/storage/in_memory/in_memory_record_store_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store_test.cpp index 40366d6f81d..6da2107aa61 100644 --- a/src/mongo/db/storage/in_memory/in_memory_record_store_test.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store_test.cpp @@ -1,4 +1,4 @@ -// in_memory_record_store_test.cpp +// ephemeral_for_test_record_store_test.cpp /** * Copyright (C) 2014 MongoDB Inc. @@ -28,30 +28,30 @@ * it in the license file. */ -#include "mongo/db/storage/in_memory/in_memory_record_store.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h" -#include "mongo/db/storage/in_memory/in_memory_recovery_unit.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h" #include "mongo/db/storage/record_store_test_harness.h" #include "mongo/unittest/unittest.h" namespace mongo { -class InMemoryHarnessHelper final : public HarnessHelper { +class EphemeralForTestHarnessHelper final : public HarnessHelper { public: - InMemoryHarnessHelper() {} + EphemeralForTestHarnessHelper() {} std::unique_ptr<RecordStore> newNonCappedRecordStore() final { - return stdx::make_unique<InMemoryRecordStore>("a.b", &data); + return stdx::make_unique<EphemeralForTestRecordStore>("a.b", &data); } std::unique_ptr<RecordStore> newCappedRecordStore(int64_t cappedSizeBytes, int64_t cappedMaxDocs) final { - return stdx::make_unique<InMemoryRecordStore>( + return stdx::make_unique<EphemeralForTestRecordStore>( "a.b", &data, true, cappedSizeBytes, cappedMaxDocs); } RecoveryUnit* newRecoveryUnit() final { - return new InMemoryRecoveryUnit(); + return new EphemeralForTestRecoveryUnit(); } bool supportsDocLocking() final { @@ -62,6 +62,6 @@ public: }; std::unique_ptr<HarnessHelper> newHarnessHelper() { - return stdx::make_unique<InMemoryHarnessHelper>(); + return stdx::make_unique<EphemeralForTestHarnessHelper>(); } } diff --git a/src/mongo/db/storage/in_memory/in_memory_recovery_unit.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.cpp index 80999a59305..016f66cdb1e 100644 --- a/src/mongo/db/storage/in_memory/in_memory_recovery_unit.cpp +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.cpp @@ -1,4 +1,4 @@ -// in_memory_recovery_unit.cpp +// ephemeral_for_test_recovery_unit.cpp /** * Copyright (C) 2014 MongoDB Inc. @@ -30,14 +30,14 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage -#include "mongo/db/storage/in_memory/in_memory_recovery_unit.h" +#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h" #include "mongo/db/storage/sorted_data_interface.h" #include "mongo/util/log.h" namespace mongo { -void InMemoryRecoveryUnit::commitUnitOfWork() { +void EphemeralForTestRecoveryUnit::commitUnitOfWork() { try { for (Changes::iterator it = _changes.begin(), end = _changes.end(); it != end; ++it) { (*it)->commit(); @@ -48,7 +48,7 @@ void InMemoryRecoveryUnit::commitUnitOfWork() { } } -void InMemoryRecoveryUnit::abortUnitOfWork() { +void EphemeralForTestRecoveryUnit::abortUnitOfWork() { try { for (Changes::reverse_iterator it = _changes.rbegin(), end = _changes.rend(); it != end; ++it) { diff --git a/src/mongo/db/storage/in_memory/in_memory_recovery_unit.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h index 895e364ef04..5eb00e16528 100644 --- a/src/mongo/db/storage/in_memory/in_memory_recovery_unit.h +++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h @@ -1,4 +1,4 @@ -// in_memory_recovery_unit.h +// ephemeral_for_test_recovery_unit.h /** * Copyright (C) 2014 MongoDB Inc. @@ -39,7 +39,7 @@ namespace mongo { class SortedDataInterface; -class InMemoryRecoveryUnit : public RecoveryUnit { +class EphemeralForTestRecoveryUnit : public RecoveryUnit { public: void beginUnitOfWork(OperationContext* opCtx) final{}; void commitUnitOfWork() final; diff --git a/src/mongo/db/storage/in_memory/in_memory_engine.cpp b/src/mongo/db/storage/in_memory/in_memory_engine.cpp deleted file mode 100644 index 46a12c28b4c..00000000000 --- a/src/mongo/db/storage/in_memory/in_memory_engine.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// in_memory_engine.cpp - -/** -* Copyright (C) 2014 MongoDB Inc. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License, version 3, -* as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* As a special exception, the copyright holders give permission to link the -* code of portions of this program with the OpenSSL library under certain -* conditions as described in each individual source file and distribute -* linked combinations including the program with the OpenSSL library. You -* must comply with the GNU Affero General Public License in all respects for -* all of the code used other than as permitted herein. If you modify file(s) -* with this exception, you may extend this exception to your version of the -* file(s), but you are not obligated to do so. If you do not wish to do so, -* delete this exception statement from your version. If you delete this -* exception statement from all source files in the program, then also delete -* it in the license file. -*/ - -#include "mongo/db/storage/in_memory/in_memory_engine.h" - -#include "mongo/db/index/index_descriptor.h" -#include "mongo/db/storage/in_memory/in_memory_btree_impl.h" -#include "mongo/db/storage/in_memory/in_memory_record_store.h" -#include "mongo/db/storage/in_memory/in_memory_recovery_unit.h" - -namespace mongo { - -RecoveryUnit* InMemoryEngine::newRecoveryUnit() { - return new InMemoryRecoveryUnit(); -} - -Status InMemoryEngine::createRecordStore(OperationContext* opCtx, - StringData ns, - StringData ident, - const CollectionOptions& options) { - // All work done in getRecordStore - return Status::OK(); -} - -RecordStore* InMemoryEngine::getRecordStore(OperationContext* opCtx, - StringData ns, - StringData ident, - const CollectionOptions& options) { - stdx::lock_guard<stdx::mutex> lk(_mutex); - if (options.capped) { - return new InMemoryRecordStore(ns, - &_dataMap[ident], - true, - options.cappedSize ? options.cappedSize : 4096, - options.cappedMaxDocs ? options.cappedMaxDocs : -1); - } else { - return new InMemoryRecordStore(ns, &_dataMap[ident]); - } -} - -Status InMemoryEngine::createSortedDataInterface(OperationContext* opCtx, - StringData ident, - const IndexDescriptor* desc) { - // All work done in getSortedDataInterface - return Status::OK(); -} - -SortedDataInterface* InMemoryEngine::getSortedDataInterface(OperationContext* opCtx, - StringData ident, - const IndexDescriptor* desc) { - stdx::lock_guard<stdx::mutex> lk(_mutex); - return getInMemoryBtreeImpl(Ordering::make(desc->keyPattern()), &_dataMap[ident]); -} - -Status InMemoryEngine::dropIdent(OperationContext* opCtx, StringData ident) { - stdx::lock_guard<stdx::mutex> lk(_mutex); - _dataMap.erase(ident); - return Status::OK(); -} - -int64_t InMemoryEngine::getIdentSize(OperationContext* opCtx, StringData ident) { - return 1; -} - -std::vector<std::string> InMemoryEngine::getAllIdents(OperationContext* opCtx) const { - std::vector<std::string> all; - { - stdx::lock_guard<stdx::mutex> lk(_mutex); - for (DataMap::const_iterator it = _dataMap.begin(); it != _dataMap.end(); ++it) { - all.push_back(it->first); - } - } - return all; -} -} diff --git a/src/mongo/db/storage/kv/SConscript b/src/mongo/db/storage/kv/SConscript index dea90abaf04..de8e5d25d64 100644 --- a/src/mongo/db/storage/kv/SConscript +++ b/src/mongo/db/storage/kv/SConscript @@ -105,6 +105,6 @@ env.CppUnitTest( '$BUILD_DIR/mongo/db/namespace_string', '$BUILD_DIR/mongo/db/catalog/collection_options', '$BUILD_DIR/mongo/db/storage/devnull/storage_devnull_core', - '$BUILD_DIR/mongo/db/storage/in_memory/in_memory_record_store', + '$BUILD_DIR/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store', ] ) |