diff options
author | Hari Khalsa <hkhalsa@10gen.com> | 2014-06-27 16:59:27 -0400 |
---|---|---|
committer | Hari Khalsa <hkhalsa@10gen.com> | 2014-07-11 14:11:10 -0400 |
commit | de724781deb23468c909acc73d98961b9c8e53c5 (patch) | |
tree | dc62db20340f45bcddba3a77f0d02008a769eed6 /src/mongo/db | |
parent | f3ba3590ce1ca1bf8f7fbb13ad8311a52df9c176 (diff) | |
download | mongo-de724781deb23468c909acc73d98961b9c8e53c5.tar.gz |
SERVER-14413 box mmapv1 further, retire structure directory
Diffstat (limited to 'src/mongo/db')
98 files changed, 494 insertions, 458 deletions
diff --git a/src/mongo/db/catalog/collection.cpp b/src/mongo/db/catalog/collection.cpp index 37d5ae84104..1fc7d39a64e 100644 --- a/src/mongo/db/catalog/collection.cpp +++ b/src/mongo/db/catalog/collection.cpp @@ -41,7 +41,7 @@ #include "mongo/db/catalog/index_create.h" #include "mongo/db/index/index_access_method.h" #include "mongo/db/operation_context.h" -#include "mongo/db/structure/record_store_v1_capped.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_capped.h" // XXX-HK/ERH #include "mongo/db/repl/repl_coordinator_global.h" #include "mongo/db/auth/user_document_parser.h" // XXX-ANDY diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h index dea27fdc77b..d789d4bb977 100644 --- a/src/mongo/db/catalog/collection.h +++ b/src/mongo/db/catalog/collection.h @@ -35,13 +35,13 @@ #include "mongo/base/string_data.h" #include "mongo/bson/mutable/damage_vector.h" #include "mongo/db/catalog/collection_cursor_cache.h" +#include "mongo/db/catalog/collection_info_cache.h" #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/diskloc.h" #include "mongo/db/exec/collection_scan_common.h" #include "mongo/db/namespace_string.h" -#include "mongo/db/structure/capped_callback.h" -#include "mongo/db/structure/record_store.h" -#include "mongo/db/catalog/collection_info_cache.h" +#include "mongo/db/storage/capped_callback.h" +#include "mongo/db/storage/record_store.h" #include "mongo/platform/cstdint.h" namespace mongo { @@ -54,8 +54,6 @@ namespace mongo { class OperationContext; class RecordIterator; - class FlatIterator; - class CappedIterator; class OpDebug; @@ -293,8 +291,6 @@ namespace mongo { mutable CollectionCursorCache _cursorCache; friend class Database; - friend class FlatIterator; - friend class CappedIterator; friend class IndexCatalog; friend class NamespaceDetails; }; diff --git a/src/mongo/db/structure/collection_compact.cpp b/src/mongo/db/catalog/collection_compact.cpp index c4d91c17168..c4d91c17168 100644 --- a/src/mongo/db/structure/collection_compact.cpp +++ b/src/mongo/db/catalog/collection_compact.cpp diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp index e9ff8027e50..0134470e79c 100644 --- a/src/mongo/db/catalog/database.cpp +++ b/src/mongo/db/catalog/database.cpp @@ -39,12 +39,12 @@ #include "mongo/db/auth/auth_index_d.h" #include "mongo/db/background.h" #include "mongo/db/clientcursor.h" +#include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/collection_catalog_entry.h" #include "mongo/db/catalog/collection_options.h" #include "mongo/db/catalog/database_catalog_entry.h" #include "mongo/db/catalog/database_holder.h" #include "mongo/db/dbhelpers.h" -#include "mongo/db/structure/catalog/index_details.h" #include "mongo/db/instance.h" #include "mongo/db/introspect.h" #include "mongo/db/repair_database.h" @@ -459,8 +459,8 @@ namespace mongo { if (NamespaceString::normal(ns)) { // This check only applies for actual collections, not indexes or other types of ns. uassert(17381, str::stream() << "fully qualified namespace " << ns << " is too long " - << "(max is " << Namespace::MaxNsColletionLen << " bytes)", - ns.size() <= Namespace::MaxNsColletionLen); + << "(max is " << NamespaceString::MaxNsCollectionLen << " bytes)", + ns.size() <= NamespaceString::MaxNsCollectionLen); } NamespaceString nss( ns ); diff --git a/src/mongo/db/structure/head_manager.h b/src/mongo/db/catalog/head_manager.h index bdb993ee3e3..bdb993ee3e3 100644 --- a/src/mongo/db/structure/head_manager.h +++ b/src/mongo/db/catalog/head_manager.h diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp index 52df950c274..ff638d55423 100644 --- a/src/mongo/db/catalog/index_catalog.cpp +++ b/src/mongo/db/catalog/index_catalog.cpp @@ -506,7 +506,7 @@ namespace mongo { return Status( ErrorCodes::CannotCreateIndex, "no index name specified" ); string indexNamespace = IndexDescriptor::makeIndexNamespace( specNamespace, name ); - if ( indexNamespace.length() > Namespace::MaxNsLen ) + if ( indexNamespace.length() > NamespaceString::MaxNsLen ) return Status( ErrorCodes::CannotCreateIndex, str::stream() << "namespace name generated from index name \"" << indexNamespace << "\" is too long (127 byte max)" ); diff --git a/src/mongo/db/catalog/index_catalog_entry.cpp b/src/mongo/db/catalog/index_catalog_entry.cpp index f60fb38dfd5..0271549681a 100644 --- a/src/mongo/db/catalog/index_catalog_entry.cpp +++ b/src/mongo/db/catalog/index_catalog_entry.cpp @@ -33,10 +33,10 @@ #include "mongo/db/catalog/index_catalog_entry.h" #include "mongo/db/catalog/collection_catalog_entry.h" +#include "mongo/db/catalog/head_manager.h" #include "mongo/db/index/index_access_method.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/operation_context.h" -#include "mongo/db/structure/head_manager.h" #include "mongo/util/file_allocator.h" #include "mongo/util/log.h" diff --git a/src/mongo/db/commands/rename_collection.cpp b/src/mongo/db/commands/rename_collection.cpp index 904041aa648..be1a74ad521 100644 --- a/src/mongo/db/commands/rename_collection.cpp +++ b/src/mongo/db/commands/rename_collection.cpp @@ -165,8 +165,8 @@ namespace mongo { } unsigned int longestAllowed = - min(int(Namespace::MaxNsColletionLen), - int(Namespace::MaxNsLen) - 2/*strlen(".$")*/ - longestIndexNameLength); + min(int(NamespaceString::MaxNsCollectionLen), + int(NamespaceString::MaxNsLen) - 2/*strlen(".$")*/ - longestIndexNameLength); if (target.size() > longestAllowed) { StringBuilder sb; sb << "collection name length of " << target.size() diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp index 41d638d4975..e69f856dc41 100644 --- a/src/mongo/db/commands/write_commands/batch_executor.cpp +++ b/src/mongo/db/commands/write_commands/batch_executor.cpp @@ -513,7 +513,7 @@ namespace mongo { currentOp->ensureStarted(); currentOp->setNS( currWrite.getRequest()->getNS() ); - currentOp->debug().ns = currentOp->getNS(); + currentOp->debug().ns = currentOp->getNS().c_str(); currentOp->debug().op = currentOp->getOp(); if ( currWrite.getOpType() == BatchedCommandRequest::BatchType_Insert ) { diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index 2f968ca4979..d4855becf24 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -64,10 +64,6 @@ namespace mongo { _op = 0; _opNum = _nextOpNum++; _command = NULL; - // These addresses should never be written to again. The zeroes are - // placed here as a precaution because currentOp may be accessed - // without the db mutex. - memset(_ns, 0, sizeof(_ns)); } void CurOp::_reset() { @@ -89,7 +85,6 @@ namespace mongo { _reset(); _start = 0; _opNum = _nextOpNum++; - _ns[0] = 0; _debug.reset(); _query.reset(); _active = true; // this should be last for ui clarity @@ -132,10 +127,10 @@ namespace mongo { } void CurOp::setNS( const StringData& ns ) { - ns.substr( 0, Namespace::MaxNsLen ).copyTo( _ns, true ); + // _ns copies the data in the null-terminated ptr it's given + _ns = ns.toString().c_str(); } - void CurOp::ensureStarted() { if ( _start == 0 ) { _start = curTimeMicros64(); @@ -151,15 +146,13 @@ namespace mongo { void CurOp::enter( Client::Context * context ) { ensureStarted(); - - strncpy( _ns, context->ns(), Namespace::MaxNsLen); - _ns[Namespace::MaxNsLen] = 0; - + _ns = context->ns(); _dbprofile = std::max( context->_db ? context->_db->getProfilingLevel() : 0 , _dbprofile ); } void CurOp::recordGlobalTime(bool isWriteLocked, long long micros) const { - Top::global.record(_ns, _op, isWriteLocked ? 1 : -1, micros, _isCommand); + string nsStr = _ns.toString(); + Top::global.record(nsStr, _op, isWriteLocked ? 1 : -1, micros, _isCommand); } void CurOp::reportState(BSONObjBuilder* builder) { @@ -174,7 +167,7 @@ namespace mongo { builder->append( "op" , opToString( _op ) ); - builder->append("ns", _ns); + builder->append("ns", _ns.toString()); if (_op == dbInsert) { _query.append(*builder, "insert"); @@ -218,7 +211,7 @@ namespace mongo { bool a = _active && _start; bob.append("active", a); bob.append( "op" , opToString( _op ) ); - bob.append("ns", _ns); + bob.append("ns", _ns.toString()); if (_op == dbInsert) { _query.append(bob, "insert"); } diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 7ae15d494b4..e895799abba 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -33,7 +33,6 @@ #include "mongo/bson/util/atomic_int.h" #include "mongo/db/client.h" -#include "mongo/db/structure/catalog/namespace.h" #include "mongo/util/concurrency/spin_lock.h" #include "mongo/util/net/hostandport.h" #include "mongo/util/progress_meter.h" @@ -117,7 +116,7 @@ namespace mongo { /* lifespan is different than CurOp because of recursives with DBDirectClient */ class OpDebug { public: - OpDebug() : ns(""), planSummary(2048) { reset(); } + OpDebug() : planSummary(2048) { reset(); } void reset(); @@ -147,7 +146,7 @@ namespace mongo { // basic options int op; bool iscommand; - Namespace ns; + ThreadSafeString ns; BSONObj query; BSONObj updateobj; @@ -204,7 +203,7 @@ namespace mongo { void markCommand() { _isCommand = true; } OpDebug& debug() { return _debug; } int profileLevel() const { return _dbprofile; } - const char * getNS() const { return _ns; } + string getNS() const { return _ns.toString(); } bool shouldDBProfile( int ms ) const { if ( _dbprofile <= 0 ) @@ -338,7 +337,7 @@ namespace mongo { bool _isCommand; int _dbprofile; // 0=off, 1=slow, 2=all AtomicUInt _opNum; // todo: simple being "unsigned" may make more sense here - char _ns[Namespace::MaxNsLen+2]; + ThreadSafeString _ns; HostAndPort _remote; // CAREFUL here with thread safety CachedBSONObj<512> _query; // CachedBSONObj is thread safe OpDebug _debug; diff --git a/src/mongo/db/index/2d_access_method.cpp b/src/mongo/db/index/2d_access_method.cpp index 05003290ad0..a4df454ab20 100644 --- a/src/mongo/db/index/2d_access_method.cpp +++ b/src/mongo/db/index/2d_access_method.cpp @@ -40,7 +40,7 @@ namespace mongo { TwoDAccessMethod::TwoDAccessMethod(IndexCatalogEntry* btreeState, - BtreeInterface* btree) + SortedDataInterface* btree) : BtreeBasedAccessMethod(btreeState, btree) { const IndexDescriptor* descriptor = btreeState->descriptor(); diff --git a/src/mongo/db/index/2d_access_method.h b/src/mongo/db/index/2d_access_method.h index 42d0f37d110..eec59cbc6a3 100644 --- a/src/mongo/db/index/2d_access_method.h +++ b/src/mongo/db/index/2d_access_method.h @@ -45,7 +45,7 @@ namespace mongo { using BtreeBasedAccessMethod::_descriptor; TwoDAccessMethod(IndexCatalogEntry* btreeState, - BtreeInterface* btree); + SortedDataInterface* btree); virtual ~TwoDAccessMethod() { } private: diff --git a/src/mongo/db/index/btree_access_method.cpp b/src/mongo/db/index/btree_access_method.cpp index f417ab3b085..eb296b0f739 100644 --- a/src/mongo/db/index/btree_access_method.cpp +++ b/src/mongo/db/index/btree_access_method.cpp @@ -39,7 +39,7 @@ namespace mongo { // Standard Btree implementation below. - BtreeAccessMethod::BtreeAccessMethod(IndexCatalogEntry* btreeState, BtreeInterface* btree ) + BtreeAccessMethod::BtreeAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree ) : BtreeBasedAccessMethod(btreeState, btree) { // The key generation wants these values. diff --git a/src/mongo/db/index/btree_access_method.h b/src/mongo/db/index/btree_access_method.h index 18da7a970f2..c776e9340b5 100644 --- a/src/mongo/db/index/btree_access_method.h +++ b/src/mongo/db/index/btree_access_method.h @@ -52,7 +52,7 @@ namespace mongo { using BtreeBasedAccessMethod::_descriptor; BtreeAccessMethod(IndexCatalogEntry* btreeState, - BtreeInterface* btree ); + SortedDataInterface* btree ); virtual ~BtreeAccessMethod() { } private: diff --git a/src/mongo/db/index/btree_based_access_method.cpp b/src/mongo/db/index/btree_based_access_method.cpp index 664aa7de94c..bfec316d271 100644 --- a/src/mongo/db/index/btree_based_access_method.cpp +++ b/src/mongo/db/index/btree_based_access_method.cpp @@ -40,8 +40,6 @@ #include "mongo/db/pdfile_private.h" #include "mongo/db/server_parameters.h" #include "mongo/db/operation_context.h" -#include "mongo/db/structure/btree/btree_interface.h" -#include "mongo/db/structure/btree/bucket_deletion_notification.h" #include "mongo/util/progress_meter.h" @@ -57,7 +55,7 @@ namespace mongo { BtreeBasedAccessMethod::InvalidateCursorsNotification BtreeBasedAccessMethod::invalidateCursors; BtreeBasedAccessMethod::BtreeBasedAccessMethod(IndexCatalogEntry* btreeState, - BtreeInterface* btree) + SortedDataInterface* btree) : _btreeState(btreeState), _descriptor(btreeState->descriptor()), _newInterface(btree) { @@ -201,7 +199,7 @@ namespace mongo { BSONObjSet keys; getKeys(obj, &keys); - boost::scoped_ptr<BtreeInterface::Cursor> cursor(_newInterface->newCursor(txn, 1)); + boost::scoped_ptr<SortedDataInterface::Cursor> cursor(_newInterface->newCursor(txn, 1)); for (BSONObjSet::const_iterator i = keys.begin(); i != keys.end(); ++i) { cursor->locate(*i, DiskLoc()); } @@ -214,8 +212,8 @@ namespace mongo { return _newInterface->touch(txn); } - DiskLoc BtreeBasedAccessMethod::findSingle( OperationContext* txn, const BSONObj& key) const { - boost::scoped_ptr<BtreeInterface::Cursor> cursor(_newInterface->newCursor(txn, 1)); + DiskLoc BtreeBasedAccessMethod::findSingle(OperationContext* txn, const BSONObj& key) const { + boost::scoped_ptr<SortedDataInterface::Cursor> cursor(_newInterface->newCursor(txn, 1)); cursor->locate(key, minDiskLoc); // A null bucket means the key wasn't found (nor was anything found after it). diff --git a/src/mongo/db/index/btree_based_access_method.h b/src/mongo/db/index/btree_based_access_method.h index 710a323b60a..7662478d2ce 100644 --- a/src/mongo/db/index/btree_based_access_method.h +++ b/src/mongo/db/index/btree_based_access_method.h @@ -36,8 +36,8 @@ #include "mongo/db/index/index_access_method.h" #include "mongo/db/index/index_cursor.h" #include "mongo/db/index/index_descriptor.h" -#include "mongo/db/structure/btree/btree_interface.h" -#include "mongo/db/structure/btree/bucket_deletion_notification.h" +#include "mongo/db/storage/sorted_data_interface.h" +#include "mongo/db/storage/mmap_v1/btree/bucket_deletion_notification.h" // XXX HK this can go away namespace mongo { @@ -58,7 +58,7 @@ namespace mongo { MONGO_DISALLOW_COPYING( BtreeBasedAccessMethod ); public: BtreeBasedAccessMethod( IndexCatalogEntry* btreeState, - BtreeInterface* btree ); + SortedDataInterface* btree ); virtual ~BtreeBasedAccessMethod() { } @@ -133,7 +133,7 @@ namespace mongo { const BSONObj& key, const DiskLoc& loc); - scoped_ptr<BtreeInterface> _newInterface; + scoped_ptr<SortedDataInterface> _newInterface; }; /** diff --git a/src/mongo/db/index/btree_based_bulk_access_method.cpp b/src/mongo/db/index/btree_based_bulk_access_method.cpp index 3e03a5d0509..ccc278354af 100644 --- a/src/mongo/db/index/btree_based_bulk_access_method.cpp +++ b/src/mongo/db/index/btree_based_bulk_access_method.cpp @@ -74,7 +74,7 @@ namespace mongo { BtreeBasedBulkAccessMethod::BtreeBasedBulkAccessMethod(OperationContext* txn, BtreeBasedAccessMethod* real, - BtreeInterface* interface, + SortedDataInterface* interface, const IndexDescriptor* descriptor) { _real = real; _interface = interface; @@ -138,7 +138,7 @@ namespace mongo { _keysInserted, 10); - scoped_ptr<BtreeBuilderInterface> builder; + scoped_ptr<SortedDataBuilderInterface> builder; builder.reset(_interface->getBulkBuilder(_txn, dupsAllowed)); diff --git a/src/mongo/db/index/btree_based_bulk_access_method.h b/src/mongo/db/index/btree_based_bulk_access_method.h index 0c766aad1ec..caf93827b1b 100644 --- a/src/mongo/db/index/btree_based_bulk_access_method.h +++ b/src/mongo/db/index/btree_based_bulk_access_method.h @@ -36,7 +36,7 @@ #include "mongo/db/index/index_access_method.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/jsobj.h" -#include "mongo/db/structure/btree/btree_interface.h" +#include "mongo/db/storage/sorted_data_interface.h" namespace mongo { @@ -48,7 +48,7 @@ namespace mongo { */ BtreeBasedBulkAccessMethod(OperationContext* txn, BtreeBasedAccessMethod* real, - BtreeInterface* interface, + SortedDataInterface* interface, const IndexDescriptor* descriptor); ~BtreeBasedBulkAccessMethod() {} @@ -135,7 +135,7 @@ namespace mongo { BtreeBasedAccessMethod* _real; // Not owned here. - BtreeInterface* _interface; + SortedDataInterface* _interface; // The external sorter. boost::scoped_ptr<BSONObjExternalSorter> _sorter; diff --git a/src/mongo/db/index/btree_index_cursor.cpp b/src/mongo/db/index/btree_index_cursor.cpp index 2038797de2b..ab05f2343af 100644 --- a/src/mongo/db/index/btree_index_cursor.cpp +++ b/src/mongo/db/index/btree_index_cursor.cpp @@ -44,7 +44,7 @@ namespace mongo { unordered_set<BtreeIndexCursor*> BtreeIndexCursor::_activeCursors; SimpleMutex BtreeIndexCursor::_activeCursorsMutex("active_btree_index_cursors"); - BtreeIndexCursor::BtreeIndexCursor(BtreeInterface::Cursor* cursor) + BtreeIndexCursor::BtreeIndexCursor(SortedDataInterface::Cursor* cursor) : _cursor(cursor) { SimpleMutex::scoped_lock lock(_activeCursorsMutex); diff --git a/src/mongo/db/index/btree_index_cursor.h b/src/mongo/db/index/btree_index_cursor.h index 93f39f08d03..f51005d449f 100644 --- a/src/mongo/db/index/btree_index_cursor.h +++ b/src/mongo/db/index/btree_index_cursor.h @@ -35,7 +35,7 @@ #include "mongo/db/jsobj.h" #include "mongo/db/index/index_cursor.h" #include "mongo/db/index/index_descriptor.h" -#include "mongo/db/structure/btree/btree_interface.h" +#include "mongo/db/storage/sorted_data_interface.h" namespace mongo { @@ -96,7 +96,7 @@ namespace mongo { * * Intentionally private, we're friends with the only class allowed to call it. */ - BtreeIndexCursor(BtreeInterface::Cursor* cursor); + BtreeIndexCursor(SortedDataInterface::Cursor* cursor); bool isSavedPositionValid(); @@ -110,7 +110,7 @@ namespace mongo { static unordered_set<BtreeIndexCursor*> _activeCursors; static SimpleMutex _activeCursorsMutex; - boost::scoped_ptr<BtreeInterface::Cursor> _cursor; + boost::scoped_ptr<SortedDataInterface::Cursor> _cursor; }; } // namespace mongo diff --git a/src/mongo/db/index/fts_access_method.cpp b/src/mongo/db/index/fts_access_method.cpp index 8630451b29d..4b8321e985c 100644 --- a/src/mongo/db/index/fts_access_method.cpp +++ b/src/mongo/db/index/fts_access_method.cpp @@ -31,7 +31,7 @@ namespace mongo { - FTSAccessMethod::FTSAccessMethod(IndexCatalogEntry* btreeState, BtreeInterface* btree ) + FTSAccessMethod::FTSAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree ) : BtreeBasedAccessMethod(btreeState, btree), _ftsSpec(btreeState->descriptor()->infoObj()) { } void FTSAccessMethod::getKeys(const BSONObj& obj, BSONObjSet* keys) { diff --git a/src/mongo/db/index/fts_access_method.h b/src/mongo/db/index/fts_access_method.h index 66d04f1957e..8ca7a26afea 100644 --- a/src/mongo/db/index/fts_access_method.h +++ b/src/mongo/db/index/fts_access_method.h @@ -38,7 +38,7 @@ namespace mongo { class FTSAccessMethod : public BtreeBasedAccessMethod { public: - FTSAccessMethod(IndexCatalogEntry* btreeState, BtreeInterface* btree ); + FTSAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree ); virtual ~FTSAccessMethod() { } const fts::FTSSpec& getSpec() const { return _ftsSpec; } diff --git a/src/mongo/db/index/hash_access_method.cpp b/src/mongo/db/index/hash_access_method.cpp index 173aaa91838..175196d4570 100644 --- a/src/mongo/db/index/hash_access_method.cpp +++ b/src/mongo/db/index/hash_access_method.cpp @@ -33,7 +33,7 @@ namespace mongo { - HashAccessMethod::HashAccessMethod(IndexCatalogEntry* btreeState, BtreeInterface* btree) + HashAccessMethod::HashAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree) : BtreeBasedAccessMethod(btreeState, btree) { const IndexDescriptor* descriptor = btreeState->descriptor(); diff --git a/src/mongo/db/index/hash_access_method.h b/src/mongo/db/index/hash_access_method.h index ff090cbfd58..9b93574249e 100644 --- a/src/mongo/db/index/hash_access_method.h +++ b/src/mongo/db/index/hash_access_method.h @@ -45,7 +45,7 @@ namespace mongo { public: using BtreeBasedAccessMethod::_descriptor; - HashAccessMethod(IndexCatalogEntry* btreeState, BtreeInterface* btree); + HashAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree); virtual ~HashAccessMethod() { } private: diff --git a/src/mongo/db/index/haystack_access_method.cpp b/src/mongo/db/index/haystack_access_method.cpp index a2fbe010a3f..f849e708d5b 100644 --- a/src/mongo/db/index/haystack_access_method.cpp +++ b/src/mongo/db/index/haystack_access_method.cpp @@ -43,7 +43,7 @@ namespace mongo { MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kQuery); - HaystackAccessMethod::HaystackAccessMethod(IndexCatalogEntry* btreeState, BtreeInterface* btree) + HaystackAccessMethod::HaystackAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree) : BtreeBasedAccessMethod(btreeState, btree) { const IndexDescriptor* descriptor = btreeState->descriptor(); diff --git a/src/mongo/db/index/haystack_access_method.h b/src/mongo/db/index/haystack_access_method.h index ebab7177a59..1d2820b3ff5 100644 --- a/src/mongo/db/index/haystack_access_method.h +++ b/src/mongo/db/index/haystack_access_method.h @@ -58,7 +58,7 @@ namespace mongo { public: using BtreeBasedAccessMethod::_descriptor; - HaystackAccessMethod(IndexCatalogEntry* btreeState, BtreeInterface* btree); + HaystackAccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree); virtual ~HaystackAccessMethod() { } protected: diff --git a/src/mongo/db/index/s2_access_method.cpp b/src/mongo/db/index/s2_access_method.cpp index 8b97e3ff556..3f4b0f95deb 100644 --- a/src/mongo/db/index/s2_access_method.cpp +++ b/src/mongo/db/index/s2_access_method.cpp @@ -43,7 +43,7 @@ namespace mongo { static const string kIndexVersionFieldName("2dsphereIndexVersion"); - S2AccessMethod::S2AccessMethod(IndexCatalogEntry* btreeState, BtreeInterface* btree) + S2AccessMethod::S2AccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree) : BtreeBasedAccessMethod(btreeState, btree) { const IndexDescriptor* descriptor = btreeState->descriptor(); diff --git a/src/mongo/db/index/s2_access_method.h b/src/mongo/db/index/s2_access_method.h index d189e8229db..773c4e04d05 100644 --- a/src/mongo/db/index/s2_access_method.h +++ b/src/mongo/db/index/s2_access_method.h @@ -43,7 +43,7 @@ namespace mongo { public: using BtreeBasedAccessMethod::_descriptor; - S2AccessMethod(IndexCatalogEntry* btreeState, BtreeInterface* btree); + S2AccessMethod(IndexCatalogEntry* btreeState, SortedDataInterface* btree); virtual ~S2AccessMethod() { } /** diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index de5048945a7..aeeead67b15 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -561,7 +561,7 @@ namespace mongo { DbMessage d(m); NamespaceString ns(d.getns()); uassertStatusOK( userAllowedWriteNS( ns ) ); - op.debug().ns = ns.ns(); + op.debug().ns = ns.ns().c_str(); int flags = d.pullInt(); BSONObj query = d.nextJsObj(); @@ -619,7 +619,7 @@ namespace mongo { NamespaceString ns(d.getns()); uassertStatusOK( userAllowedWriteNS( ns ) ); - op.debug().ns = ns.ns(); + op.debug().ns = ns.ns().c_str(); int flags = d.pullInt(); bool justOne = flags & RemoveOption_JustOne; bool broadcast = flags & RemoveOption_Broadcast; diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h index 53ed2447fb4..b5963a8ce89 100644 --- a/src/mongo/db/namespace_string.h +++ b/src/mongo/db/namespace_string.h @@ -70,6 +70,23 @@ namespace mongo { */ NamespaceString( const StringData& dbName, const StringData& collectionName ); + /** + * Note that these values are derived from the mmap_v1 implementation and that + * is the only reason they are constrained as such. + */ + enum MaxNsLenValue { + // Maximum possible length of name any namespace, including special ones like $extra. + // This includes rum for the NUL byte so it can be used when sizing buffers. + MaxNsLenWithNUL = 128, + + // MaxNsLenWithNUL excluding the NUL byte. Use this when comparing std::string lengths. + MaxNsLen = MaxNsLenWithNUL - 1, + + // Maximum allowed length of fully qualified namespace name of any real collection. + // Does not include NUL so it can be directly compared to std::string lengths. + MaxNsCollectionLen = MaxNsLen - 7/*strlen(".$extra")*/, + }; + StringData db() const; StringData coll() const; diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h index bab1b555e51..bebf33de6cb 100644 --- a/src/mongo/db/operation_context.h +++ b/src/mongo/db/operation_context.h @@ -91,9 +91,11 @@ namespace mongo { int secondsBetween = 3) = 0; /** - * Delegates to CurOp, but is included here to break dependencies + * Delegates to CurOp, but is included here to break dependencies. + * + * TODO: We return a string because of hopefully transient CurOp thread-unsafe insanity. */ - virtual const char * getNS() const = 0; + virtual string getNS() const = 0; /** * Returns the client under which this context runs. diff --git a/src/mongo/db/operation_context_impl.cpp b/src/mongo/db/operation_context_impl.cpp index 4af1def603c..83184591bd0 100644 --- a/src/mongo/db/operation_context_impl.cpp +++ b/src/mongo/db/operation_context_impl.cpp @@ -66,7 +66,7 @@ namespace mongo { return &getCurOp()->setMessage(msg, name, progressMeterTotal, secondsBetween); } - const char* OperationContextImpl::getNS() const { + string OperationContextImpl::getNS() const { return getCurOp()->getNS(); } diff --git a/src/mongo/db/operation_context_impl.h b/src/mongo/db/operation_context_impl.h index ed681f1940a..6d0c93c1546 100644 --- a/src/mongo/db/operation_context_impl.h +++ b/src/mongo/db/operation_context_impl.h @@ -50,7 +50,7 @@ namespace mongo { unsigned long long progressMeterTotal, int secondsBetween); - virtual const char * getNS() const; + virtual string getNS() const; virtual Client* getClient() const; diff --git a/src/mongo/db/operation_context_noop.h b/src/mongo/db/operation_context_noop.h index f3964494936..a4dd040c27f 100644 --- a/src/mongo/db/operation_context_noop.h +++ b/src/mongo/db/operation_context_noop.h @@ -85,8 +85,8 @@ namespace mongo { return true; } - virtual const char * getNS() const { - return NULL; + virtual string getNS() const { + return string(); }; virtual Transaction* getTransaction() { diff --git a/src/mongo/db/ops/insert.cpp b/src/mongo/db/ops/insert.cpp index 5e38b76412b..22613fdaf04 100644 --- a/src/mongo/db/ops/insert.cpp +++ b/src/mongo/db/ops/insert.cpp @@ -30,7 +30,6 @@ #include "mongo/db/ops/insert.h" #include "mongo/db/global_optime.h" -#include "mongo/db/structure/catalog/namespace.h" #include "mongo/util/mongoutils/str.h" namespace mongo { @@ -154,11 +153,11 @@ namespace mongo { if ( !NamespaceString::validCollectionName( coll ) ) return Status( ErrorCodes::BadValue, "invalid collection name" ); - if ( db.size() + 1 /* dot */ + coll.size() > Namespace::MaxNsColletionLen ) + if ( db.size() + 1 /* dot */ + coll.size() > NamespaceString::MaxNsCollectionLen ) return Status( ErrorCodes::BadValue, str::stream() << "fully qualified namespace " << db << '.' << coll << " is too long " - << "(max is " << Namespace::MaxNsColletionLen << " bytes)" ); + << "(max is " << NamespaceString::MaxNsCollectionLen << " bytes)" ); // check spceial areas diff --git a/src/mongo/db/structure/capped_callback.h b/src/mongo/db/storage/capped_callback.h index 59c23f9dab9..59c23f9dab9 100644 --- a/src/mongo/db/structure/capped_callback.h +++ b/src/mongo/db/storage/capped_callback.h diff --git a/src/mongo/db/storage/heap1/SConscript b/src/mongo/db/storage/heap1/SConscript index 0b1a6db0383..feb9fcbb2d1 100644 --- a/src/mongo/db/storage/heap1/SConscript +++ b/src/mongo/db/storage/heap1/SConscript @@ -8,9 +8,20 @@ env.Library( 'heap1_engine.cpp', ], LIBDEPS= [ + 'heap_record_store', '$BUILD_DIR/mongo/bson', '$BUILD_DIR/mongo/db/catalog/collection_options', - '$BUILD_DIR/mongo/db/structure/record_store', + '$BUILD_DIR/mongo/foundation', + ] + ) + +env.Library( + target= 'heap_record_store', + source= [ + 'record_store_heap.cpp' + ], + LIBDEPS= [ + '$BUILD_DIR/mongo/bson', '$BUILD_DIR/mongo/foundation', ] ) diff --git a/src/mongo/db/storage/heap1/heap1_btree_impl.cpp b/src/mongo/db/storage/heap1/heap1_btree_impl.cpp index 2d5ae2fc63b..9a2ec04417a 100644 --- a/src/mongo/db/storage/heap1/heap1_btree_impl.cpp +++ b/src/mongo/db/storage/heap1/heap1_btree_impl.cpp @@ -200,7 +200,7 @@ namespace { return it->loc != loc; } - class Heap1BtreeBuilderImpl : public BtreeBuilderInterface { + class Heap1BtreeBuilderImpl : public SortedDataBuilderInterface { public: Heap1BtreeBuilderImpl(IndexSet* data, bool dupsAllowed) : _data(data), @@ -241,14 +241,14 @@ namespace { bool _committed; }; - class Heap1BtreeImpl : public BtreeInterface { + class Heap1BtreeImpl : public SortedDataInterface { public: Heap1BtreeImpl(const IndexCatalogEntry& info, IndexSet* data) : _info(info), _data(data) {} - virtual BtreeBuilderInterface* getBulkBuilder(OperationContext* txn, bool dupsAllowed) { + virtual SortedDataBuilderInterface* getBulkBuilder(OperationContext* txn, bool dupsAllowed) { return new Heap1BtreeBuilderImpl(_data, dupsAllowed); } @@ -300,7 +300,7 @@ namespace { return Status::OK(); } - class ForwardCursor : public BtreeInterface::Cursor { + class ForwardCursor : public SortedDataInterface::Cursor { public: ForwardCursor(const IndexSet& data, OperationContext* txn) : _txn(txn), @@ -314,7 +314,7 @@ namespace { return _it == _data.end(); } - virtual bool pointsToSamePlaceAs(const BtreeInterface::Cursor& otherBase) const { + virtual bool pointsToSamePlaceAs(const SortedDataInterface::Cursor& otherBase) const { const ForwardCursor& other = static_cast<const ForwardCursor&>(otherBase); invariant(&_data == &other._data); // iterators over same index return _it == other._it; @@ -399,7 +399,7 @@ namespace { }; // TODO see if this can share any code with ForwardIterator - class ReverseCursor : public BtreeInterface::Cursor { + class ReverseCursor : public SortedDataInterface::Cursor { public: ReverseCursor(const IndexSet& data, OperationContext* txn) : _txn(txn), @@ -413,7 +413,7 @@ namespace { return _it == _data.rend(); } - virtual bool pointsToSamePlaceAs(const BtreeInterface::Cursor& otherBase) const { + virtual bool pointsToSamePlaceAs(const SortedDataInterface::Cursor& otherBase) const { const ReverseCursor& other = static_cast<const ReverseCursor&>(otherBase); invariant(&_data == &other._data); // iterators over same index return _it == other._it; @@ -512,7 +512,7 @@ namespace { DiskLoc _savedLoc; }; - virtual BtreeInterface::Cursor* newCursor(OperationContext* txn, int direction) const { + virtual SortedDataInterface::Cursor* newCursor(OperationContext* txn, int direction) const { if (direction == 1) return new ForwardCursor(*_data, txn); @@ -533,7 +533,7 @@ namespace { // IndexCatalogEntry argument taken by non-const pointer for consistency with other Btree // factories. We don't actually modify it. - BtreeInterface* getHeap1BtreeImpl(IndexCatalogEntry* info, boost::shared_ptr<void>* dataInOut) { + SortedDataInterface* getHeap1BtreeImpl(IndexCatalogEntry* info, boost::shared_ptr<void>* dataInOut) { invariant(info); invariant(dataInOut); if (!*dataInOut) { diff --git a/src/mongo/db/storage/heap1/heap1_btree_impl.h b/src/mongo/db/storage/heap1/heap1_btree_impl.h index 72b38ce3696..7187dc589dc 100644 --- a/src/mongo/db/storage/heap1/heap1_btree_impl.h +++ b/src/mongo/db/storage/heap1/heap1_btree_impl.h @@ -28,17 +28,18 @@ #include <boost/shared_ptr.hpp> -#include "mongo/db/structure/btree/btree_interface.h" +#include "mongo/db/storage/sorted_data_interface.h" #pragma once namespace mongo { + class IndexCatalogEntry; /** * Caller takes ownership. * All permanent data will be stored and fetch from dataInOut. */ - BtreeInterface* getHeap1BtreeImpl(IndexCatalogEntry* info, boost::shared_ptr<void>* dataInOut); + SortedDataInterface* getHeap1BtreeImpl(IndexCatalogEntry* info, boost::shared_ptr<void>* dataInOut); } // namespace mongo diff --git a/src/mongo/db/storage/heap1/heap1_database_catalog_entry.cpp b/src/mongo/db/storage/heap1/heap1_database_catalog_entry.cpp index 53dea7f10c7..58e069d9863 100644 --- a/src/mongo/db/storage/heap1/heap1_database_catalog_entry.cpp +++ b/src/mongo/db/storage/heap1/heap1_database_catalog_entry.cpp @@ -1,32 +1,30 @@ -// heap1_database_catalog_entry.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. -*/ + * 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/heap1/heap1_database_catalog_entry.h" @@ -43,7 +41,7 @@ #include "mongo/db/operation_context.h" #include "mongo/db/storage/heap1/heap1_btree_impl.h" #include "mongo/db/storage/heap1/heap1_recovery_unit.h" -#include "mongo/db/structure/record_store_heap.h" +#include "mongo/db/storage/heap1/record_store_heap.h" namespace mongo { @@ -159,14 +157,14 @@ namespace mongo { index->headManager()->setHead(txn, DiskLoc(0xDEAD, 0xBEAF)); // When is a btree not a Btree? When it is a Heap1BtreeImpl! - std::auto_ptr<BtreeInterface> btree(getHeap1BtreeImpl(index, &i->second->data)); + std::auto_ptr<SortedDataInterface> btree(getHeap1BtreeImpl(index, &i->second->data)); #else if (!i->second->rs) i->second->rs.reset(new HeapRecordStore( index->descriptor()->indexName() )); - std::auto_ptr<BtreeInterface> btree( - BtreeInterface::getInterface(index->headManager(), + std::auto_ptr<SortedDataInterface> btree( + SortedDataInterface::getInterface(index->headManager(), i->second->rs, index->ordering(), index->descriptor()->indexNamespace(), diff --git a/src/mongo/db/structure/record_store_heap.cpp b/src/mongo/db/storage/heap1/record_store_heap.cpp index 789b8e2fedd..e0578dc5c71 100644 --- a/src/mongo/db/structure/record_store_heap.cpp +++ b/src/mongo/db/storage/heap1/record_store_heap.cpp @@ -1,36 +1,33 @@ -// record_store_heap.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/operation_context_noop.h" -#include "mongo/db/structure/record_store_heap.h" + * 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/heap1/record_store_heap.h" namespace mongo { @@ -493,4 +490,5 @@ namespace mongo { RecordData HeapRecordReverseIterator::dataFor(const DiskLoc& loc) const { return _rs.dataFor(loc); } + } // namespace mongo diff --git a/src/mongo/db/structure/record_store_heap.h b/src/mongo/db/storage/heap1/record_store_heap.h index 59959c4c968..f4810b04972 100644 --- a/src/mongo/db/structure/record_store_heap.h +++ b/src/mongo/db/storage/heap1/record_store_heap.h @@ -33,10 +33,11 @@ #include <boost/shared_array.hpp> #include <map> -#include "mongo/db/structure/capped_callback.h" -#include "mongo/db/structure/record_store.h" +#include "mongo/db/storage/capped_callback.h" +#include "mongo/db/storage/record_store.h" namespace mongo { + class HeapRecordIterator; /** diff --git a/src/mongo/db/storage/mmap_v1/SConscript b/src/mongo/db/storage/mmap_v1/SConscript index 5f7ac5eabd2..11b6b06b3e7 100644 --- a/src/mongo/db/storage/mmap_v1/SConscript +++ b/src/mongo/db/storage/mmap_v1/SConscript @@ -1,6 +1,34 @@ Import("env") env.Library( + target = 'storage_mmapv1', + source = [ "catalog/index_details.cpp", + "catalog/namespace.cpp", + "catalog/namespace_details.cpp", + "catalog/namespace_details_collection_entry.cpp", + "catalog/namespace_details_rsv1_metadata.cpp", + "catalog/namespace_index.cpp", + "data_file.cpp", + "durable_mapped_file.cpp", + "dur.cpp", + "durop.cpp", + "dur_writetodatafiles.cpp", + "dur_preplogbuffer.cpp", + "dur_commitjob.cpp", + "dur_recover.cpp", + "dur_journal.cpp", + "dur_recovery_unit.cpp", + "mmap_v1_database_catalog_entry.cpp", + "mmap_v1_engine.cpp", + "mmap_v1_extent_manager.cpp", + "repair_database.cpp", + ], + LIBDEPS = [ + 'record_store_v1', + 'btree'] + ) + +env.Library( target= 'extent', source= [ 'extent.cpp', @@ -11,3 +39,94 @@ env.Library( '$BUILD_DIR/mongo/foundation', ] ) + +env.Library( + target= 'record_store_v1', + source= [ + 'record_store_v1_base.cpp', + 'record_store_v1_capped.cpp', + 'record_store_v1_capped_iterator.cpp', + 'record_store_v1_repair_iterator.cpp', + 'record_store_v1_simple.cpp', + 'record_store_v1_simple_iterator.cpp', + ], + LIBDEPS= [ + 'extent', + '$BUILD_DIR/mongo/mongocommon', # for ProgressMeter + '$BUILD_DIR/mongo/db/commands/server_status_core', + ] + ) + +env.Library( + target='record_store_v1_test_help', + source=['record_store_v1_test_help.cpp', + ], + LIBDEPS=[ + 'record_store_v1' + ] + ) + +env.CppUnitTest(target = 'namespace_test', + source = ['catalog/namespace_test.cpp'], + LIBDEPS = ['$BUILD_DIR/mongo/foundation']) + +env.CppUnitTest( + target='record_store_v1_simple_test', + source=['record_store_v1_simple_test.cpp', + ], + LIBDEPS=[ + 'record_store_v1_test_help' + ] + ) + +env.CppUnitTest( + target='record_store_v1_capped_test', + source=['record_store_v1_capped_test.cpp', + ], + LIBDEPS=[ + 'record_store_v1_test_help' + ] + ) + +env.Library( + target= 'btree', + source= [ + 'btree/btree_logic.cpp', + 'btree/btree_interface.cpp', + 'btree/key.cpp' + ], + LIBDEPS= [ + '$BUILD_DIR/mongo/bson' + ] + ) + +env.Library( + target= 'btree_test_help', + source= [ + 'btree/btree_test_help.cpp' + ], + LIBDEPS= [ + 'btree', + '$BUILD_DIR/mongo/mongocommon', # for ProgressMeter + '$BUILD_DIR/mongo/db/storage/mmap_v1/record_store_v1_test_help', + '$BUILD_DIR/mongo/db/storage/heap1/heap_record_store' # XXX? + ] + ) + +env.CppUnitTest( + target='btree_logic_test', + source=['btree/btree_logic_test.cpp' + ], + LIBDEPS=[ + 'btree_test_help' + ] + ) + +env.CppUnitTest( + target='btree_builder_test', + source=['btree/btree_builder_test.cpp' + ], + LIBDEPS=[ + 'btree_test_help' + ] + ) diff --git a/src/mongo/db/structure/btree/btree_builder_test.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_builder_test.cpp index 03714394354..89d2ffc4d98 100644 --- a/src/mongo/db/structure/btree/btree_builder_test.cpp +++ b/src/mongo/db/storage/mmap_v1/btree/btree_builder_test.cpp @@ -33,7 +33,7 @@ #include "mongo/db/instance.h" #include "mongo/db/operation_context_noop.h" -#include "mongo/db/structure/btree/btree_test_help.h" +#include "mongo/db/storage/mmap_v1/btree/btree_test_help.h" #include "mongo/unittest/unittest.h" namespace mongo { diff --git a/src/mongo/db/structure/btree/btree_interface.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_interface.cpp index ef5efccf832..6d2fae7bffa 100644 --- a/src/mongo/db/structure/btree/btree_interface.cpp +++ b/src/mongo/db/storage/mmap_v1/btree/btree_interface.cpp @@ -26,16 +26,16 @@ * it in the license file. */ -#include "mongo/db/structure/btree/btree_interface.h" +#include "mongo/db/storage/sorted_data_interface.h" #include "mongo/db/operation_context.h" -#include "mongo/db/structure/btree/btree_logic.h" +#include "mongo/db/storage/mmap_v1/btree/btree_logic.h" namespace mongo { template <class OnDiskFormat> - class BtreeBuilderInterfaceImpl : public BtreeBuilderInterface { + class BtreeBuilderInterfaceImpl : public SortedDataBuilderInterface { public: BtreeBuilderInterfaceImpl(OperationContext* trans, typename BtreeLogic<OnDiskFormat>::Builder* builder) @@ -59,13 +59,13 @@ namespace mongo { }; template <class OnDiskFormat> - class BtreeInterfaceImpl : public BtreeInterface { + class BtreeInterfaceImpl : public SortedDataInterface { public: BtreeInterfaceImpl(HeadManager* headManager, - RecordStore* recordStore, - const Ordering& ordering, - const string& indexName, - BucketDeletionNotification* bucketDeletionNotification) { + RecordStore* recordStore, + const Ordering& ordering, + const string& indexName, + BucketDeletionNotification* bucketDeletionNotification) { _btree.reset(new BtreeLogic<OnDiskFormat>(headManager, recordStore, @@ -76,8 +76,8 @@ namespace mongo { virtual ~BtreeInterfaceImpl() { } - virtual BtreeBuilderInterface* getBulkBuilder(OperationContext* txn, - bool dupsAllowed) { + virtual SortedDataBuilderInterface* getBulkBuilder(OperationContext* txn, + bool dupsAllowed) { return new BtreeBuilderInterfaceImpl<OnDiskFormat>( txn, _btree->newBuilder(txn, dupsAllowed)); @@ -116,7 +116,7 @@ namespace mongo { return _btree->touch(txn); } - class Cursor : public BtreeInterface::Cursor { + class Cursor : public SortedDataInterface::Cursor { public: Cursor(OperationContext* txn, const BtreeLogic<OnDiskFormat>* btree, @@ -132,7 +132,7 @@ namespace mongo { virtual bool isEOF() const { return _bucket.isNull(); } - virtual bool pointsToSamePlaceAs(const BtreeInterface::Cursor& otherBase) const { + virtual bool pointsToSamePlaceAs(const SortedDataInterface::Cursor& otherBase) const { const Cursor& other = static_cast<const Cursor&>(otherBase); if (isEOF()) return other.isEOF(); @@ -239,13 +239,12 @@ namespace mongo { scoped_ptr<BtreeLogic<OnDiskFormat> > _btree; }; - // static - BtreeInterface* BtreeInterface::getInterface(HeadManager* headManager, - RecordStore* recordStore, - const Ordering& ordering, - const string& indexName, - int version, - BucketDeletionNotification* bucketDeletion) { + SortedDataInterface* getMMAPV1Interface(HeadManager* headManager, + RecordStore* recordStore, + const Ordering& ordering, + const string& indexName, + int version, + BucketDeletionNotification* bucketDeletion) { if (0 == version) { return new BtreeInterfaceImpl<BtreeLayoutV0>(headManager, diff --git a/src/mongo/db/structure/record_store.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_interface.h index e7a64901d03..ad0d07b7ece 100644 --- a/src/mongo/db/structure/record_store.cpp +++ b/src/mongo/db/storage/mmap_v1/btree/btree_interface.h @@ -1,7 +1,5 @@ -// record_store.cpp - /** - * Copyright (C) 2013 10gen Inc. + * 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, @@ -28,15 +26,25 @@ * it in the license file. */ -#include "mongo/db/structure/record_store.h" +#include "mongo/bson/ordering.h" +#include "mongo/db/catalog/head_manager.h" +#include "mongo/db/diskloc.h" +#include "mongo/db/jsobj.h" +#include "mongo/db/operation_context.h" +#include "mongo/db/storage/record_store.h" +#include "mongo/db/storage/sorted_data_interface.h" + +#pragma once namespace mongo { - RecordStore::RecordStore( const StringData& ns ) - : _ns( ns.toString() ) { - } + class BucketDeletionNotification; - RecordStore::~RecordStore() { - } + SortedDataInterface* getMMAPV1Interface(HeadManager* headManager, + RecordStore* recordStore, + const Ordering& ordering, + const string& indexName, + int version, + BucketDeletionNotification* bucketDeletion); -} +} // namespace mongo diff --git a/src/mongo/db/structure/btree/btree_logic.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp index 8d05a65ab0c..93f802bc4a5 100644 --- a/src/mongo/db/structure/btree/btree_logic.cpp +++ b/src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp @@ -31,10 +31,11 @@ #include "mongo/db/diskloc.h" #include "mongo/db/jsobj.h" #include "mongo/db/operation_context.h" -#include "mongo/db/structure/btree/btree_logic.h" -#include "mongo/db/structure/btree/key.h" -#include "mongo/db/structure/record_store.h" +#include "mongo/db/storage/mmap_v1/btree/btree_logic.h" +#include "mongo/db/storage/mmap_v1/btree/key.h" +#include "mongo/db/storage/record_store.h" #include "mongo/util/log.h" +#include "mongo/util/mongoutils/str.h" namespace mongo { diff --git a/src/mongo/db/structure/btree/btree_logic.h b/src/mongo/db/storage/mmap_v1/btree/btree_logic.h index b7a31f80f52..ff7d7718de9 100644 --- a/src/mongo/db/structure/btree/btree_logic.h +++ b/src/mongo/db/storage/mmap_v1/btree/btree_logic.h @@ -28,14 +28,14 @@ #pragma once +#include "mongo/db/catalog/head_manager.h" #include "mongo/db/catalog/index_catalog_entry.h" #include "mongo/db/diskloc.h" #include "mongo/db/jsobj.h" #include "mongo/db/operation_context.h" -#include "mongo/db/structure/btree/btree_ondisk.h" -#include "mongo/db/structure/btree/key.h" -#include "mongo/db/structure/btree/bucket_deletion_notification.h" -#include "mongo/db/structure/head_manager.h" +#include "mongo/db/storage/mmap_v1/btree/btree_ondisk.h" +#include "mongo/db/storage/mmap_v1/btree/key.h" +#include "mongo/db/storage/mmap_v1/btree/bucket_deletion_notification.h" namespace mongo { diff --git a/src/mongo/db/structure/btree/btree_logic_test.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_logic_test.cpp index 3cfa48a3a25..ca6cdce9a9e 100644 --- a/src/mongo/db/structure/btree/btree_logic_test.cpp +++ b/src/mongo/db/storage/mmap_v1/btree/btree_logic_test.cpp @@ -34,7 +34,7 @@ #include "mongo/db/instance.h" #include "mongo/db/operation_context_noop.h" -#include "mongo/db/structure/btree/btree_test_help.h" +#include "mongo/db/storage/mmap_v1/btree/btree_test_help.h" #include "mongo/unittest/unittest.h" diff --git a/src/mongo/db/structure/btree/btree_ondisk.h b/src/mongo/db/storage/mmap_v1/btree/btree_ondisk.h index fd343db111f..7f91cd2fb27 100644 --- a/src/mongo/db/structure/btree/btree_ondisk.h +++ b/src/mongo/db/storage/mmap_v1/btree/btree_ondisk.h @@ -29,9 +29,8 @@ #pragma once #include "mongo/db/diskloc.h" -#include "mongo/db/storage/mmap_v1/dur.h" #include "mongo/db/jsobj.h" -#include "mongo/db/structure/btree/key.h" +#include "mongo/db/storage/mmap_v1/btree/key.h" namespace mongo { diff --git a/src/mongo/db/structure/btree/btree_test_help.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_test_help.cpp index a2deff60d27..99385d46e86 100644 --- a/src/mongo/db/structure/btree/btree_test_help.cpp +++ b/src/mongo/db/storage/mmap_v1/btree/btree_test_help.cpp @@ -29,7 +29,7 @@ * then also delete it in the license file. */ -#include "mongo/db/structure/btree/btree_test_help.h" +#include "mongo/db/storage/mmap_v1/btree/btree_test_help.h" #include "mongo/db/operation_context_noop.h" #include "mongo/unittest/unittest.h" diff --git a/src/mongo/db/structure/btree/btree_test_help.h b/src/mongo/db/storage/mmap_v1/btree/btree_test_help.h index 3dcc8c5986d..52d468f053a 100644 --- a/src/mongo/db/structure/btree/btree_test_help.h +++ b/src/mongo/db/storage/mmap_v1/btree/btree_test_help.h @@ -31,9 +31,9 @@ #include <string> #include "mongo/db/json.h" -#include "mongo/db/structure/btree/btree_logic.h" -#include "mongo/db/structure/record_store_heap.h" -#include "mongo/db/structure/record_store_v1_test_help.h" +#include "mongo/db/storage/heap1/record_store_heap.h" // XXX why is this here? +#include "mongo/db/storage/mmap_v1//btree/btree_logic.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_test_help.h" namespace mongo { diff --git a/src/mongo/db/structure/btree/bucket_deletion_notification.h b/src/mongo/db/storage/mmap_v1/btree/bucket_deletion_notification.h index 5d6fa99434f..5d6fa99434f 100644 --- a/src/mongo/db/structure/btree/bucket_deletion_notification.h +++ b/src/mongo/db/storage/mmap_v1/btree/bucket_deletion_notification.h diff --git a/src/mongo/db/structure/btree/key.cpp b/src/mongo/db/storage/mmap_v1/btree/key.cpp index 7cf1d5e7443..a6ccd61d2cf 100644 --- a/src/mongo/db/structure/btree/key.cpp +++ b/src/mongo/db/storage/mmap_v1/btree/key.cpp @@ -1,36 +1,32 @@ -// @file key.cpp - /** -* Copyright (C) 2011 10gen 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/pch.h" - -#include "mongo/db/structure/btree/key.h" + * Copyright (C) 2011 10gen 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/mmap_v1/btree/key.h" #include "mongo/bson/util/builder.h" #include "mongo/platform/float_utils.h" @@ -692,4 +688,4 @@ namespace mongo { } } cunittest; -} +} // namespace mongo diff --git a/src/mongo/db/structure/btree/key.h b/src/mongo/db/storage/mmap_v1/btree/key.h index 83203b0fee2..83203b0fee2 100644 --- a/src/mongo/db/structure/btree/key.h +++ b/src/mongo/db/storage/mmap_v1/btree/key.h diff --git a/src/mongo/db/structure/catalog/hashtab.h b/src/mongo/db/storage/mmap_v1/catalog/hashtab.h index 07916dc873d..07916dc873d 100644 --- a/src/mongo/db/structure/catalog/hashtab.h +++ b/src/mongo/db/storage/mmap_v1/catalog/hashtab.h diff --git a/src/mongo/db/structure/catalog/index_details.cpp b/src/mongo/db/storage/mmap_v1/catalog/index_details.cpp index d9ab4b51003..bc9cc3ee791 100644 --- a/src/mongo/db/structure/catalog/index_details.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/index_details.cpp @@ -28,7 +28,7 @@ * it in the license file. */ -#include "mongo/db/structure/catalog/index_details.h" +#include "mongo/db/storage/mmap_v1/catalog/index_details.h" namespace mongo { diff --git a/src/mongo/db/structure/catalog/index_details.h b/src/mongo/db/storage/mmap_v1/catalog/index_details.h index b2f34ec0681..b2f34ec0681 100644 --- a/src/mongo/db/structure/catalog/index_details.h +++ b/src/mongo/db/storage/mmap_v1/catalog/index_details.h diff --git a/src/mongo/db/structure/catalog/namespace-inl.h b/src/mongo/db/storage/mmap_v1/catalog/namespace-inl.h index 5cd45963f1f..5cd45963f1f 100644 --- a/src/mongo/db/structure/catalog/namespace-inl.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace-inl.h diff --git a/src/mongo/db/structure/catalog/namespace.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace.cpp index 1b50d0e6c6c..822ed26dedb 100644 --- a/src/mongo/db/structure/catalog/namespace.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace.cpp @@ -30,7 +30,7 @@ #include "mongo/pch.h" -#include "mongo/db/structure/catalog/namespace.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace.h" #include <boost/static_assert.hpp> @@ -40,6 +40,10 @@ namespace mongo { namespace { BOOST_STATIC_ASSERT( sizeof(Namespace) == 128 ); BOOST_STATIC_ASSERT( Namespace::MaxNsLenWithNUL == MaxDatabaseNameLen ); + BOOST_STATIC_ASSERT((int)Namespace::MaxNsLenWithNUL == (int)NamespaceString::MaxNsLenWithNUL); + BOOST_STATIC_ASSERT((int)Namespace::MaxNsLen == (int)NamespaceString::MaxNsLen); + // Note the typo. + BOOST_STATIC_ASSERT((int)Namespace::MaxNsColletionLen == (int)NamespaceString::MaxNsCollectionLen); } } diff --git a/src/mongo/db/structure/catalog/namespace.h b/src/mongo/db/storage/mmap_v1/catalog/namespace.h index 02c8721b0cf..40e70ac9857 100644 --- a/src/mongo/db/structure/catalog/namespace.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace.h @@ -89,4 +89,4 @@ namespace mongo { } // namespace mongo -#include "mongo/db/structure/catalog/namespace-inl.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace-inl.h" diff --git a/src/mongo/db/structure/catalog/namespace_details.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp index a48f5ac75df..2fe3d226e5d 100644 --- a/src/mongo/db/structure/catalog/namespace_details.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp @@ -28,7 +28,7 @@ #include "mongo/pch.h" -#include "mongo/db/structure/catalog/namespace_details.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_details.h" #include <algorithm> #include <list> @@ -43,7 +43,7 @@ #include "mongo/db/json.h" #include "mongo/db/ops/delete.h" #include "mongo/db/ops/update.h" -#include "mongo/db/structure/catalog/hashtab.h" +#include "mongo/db/storage/mmap_v1/catalog/hashtab.h" #include "mongo/db/operation_context.h" #include "mongo/scripting/engine.h" #include "mongo/util/startup_test.h" diff --git a/src/mongo/db/structure/catalog/namespace_details.h b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.h index 258d1210416..0a6734e7d9d 100644 --- a/src/mongo/db/structure/catalog/namespace_details.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.h @@ -30,9 +30,9 @@ #include "mongo/db/diskloc.h" #include "mongo/db/namespace_string.h" -#include "mongo/db/structure/catalog/index_details.h" -#include "mongo/db/structure/catalog/namespace.h" -#include "mongo/db/structure/catalog/namespace_index.h" +#include "mongo/db/storage/mmap_v1/catalog/index_details.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_index.h" namespace mongo { diff --git a/src/mongo/db/structure/catalog/namespace_details_collection_entry.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp index 16bfb2cc5cc..27957a297a5 100644 --- a/src/mongo/db/structure/catalog/namespace_details_collection_entry.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.cpp @@ -28,12 +28,12 @@ * it in the license file. */ -#include "mongo/db/structure/catalog/namespace_details_collection_entry.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h" #include "mongo/db/index/index_descriptor.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_details.h" #include "mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.h" -#include "mongo/db/structure/catalog/namespace_details.h" -#include "mongo/db/structure/record_store.h" +#include "mongo/db/storage/record_store.h" #include "mongo/util/startup_test.h" namespace mongo { diff --git a/src/mongo/db/structure/catalog/namespace_details_collection_entry.h b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h index 78a5b96f181..78a5b96f181 100644 --- a/src/mongo/db/structure/catalog/namespace_details_collection_entry.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h diff --git a/src/mongo/db/structure/catalog/namespace_details_rsv1_metadata.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.cpp index 4b03af168c8..2f168bd19a6 100644 --- a/src/mongo/db/structure/catalog/namespace_details_rsv1_metadata.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.cpp @@ -29,7 +29,7 @@ */ #include "mongo/db/ops/update.h" -#include "mongo/db/structure/catalog/namespace_details_rsv1_metadata.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.h" namespace mongo { NamespaceDetailsRSV1MetaData::NamespaceDetailsRSV1MetaData( const StringData& ns, diff --git a/src/mongo/db/structure/catalog/namespace_details_rsv1_metadata.h b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.h index 7e8ab9af7a7..9f933d003e5 100644 --- a/src/mongo/db/structure/catalog/namespace_details_rsv1_metadata.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.h @@ -33,8 +33,8 @@ #include <string> #include "mongo/base/string_data.h" -#include "mongo/db/structure/catalog/namespace_details.h" -#include "mongo/db/structure/record_store_v1_base.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_details.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_base.h" namespace mongo { diff --git a/src/mongo/db/structure/catalog/namespace_index.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.cpp index 1dd89776015..9bbf8ef6303 100644 --- a/src/mongo/db/structure/catalog/namespace_index.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.cpp @@ -29,14 +29,13 @@ */ #include "mongo/platform/basic.h" - -#include "mongo/db/structure/catalog/namespace_index.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_index.h" #include <boost/filesystem/operations.hpp> #include "mongo/db/d_concurrency.h" #include "mongo/db/operation_context.h" -#include "mongo/db/structure/catalog/namespace_details.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_details.h" #include "mongo/util/exit.h" #include "mongo/util/log.h" diff --git a/src/mongo/db/structure/catalog/namespace_index.h b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.h index 9601464520b..3ce2c2e0194 100644 --- a/src/mongo/db/structure/catalog/namespace_index.h +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.h @@ -35,8 +35,8 @@ #include "mongo/base/disallow_copying.h" #include "mongo/db/diskloc.h" -#include "mongo/db/structure/catalog/hashtab.h" -#include "mongo/db/structure/catalog/namespace.h" +#include "mongo/db/storage/mmap_v1/catalog/hashtab.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace.h" namespace mongo { diff --git a/src/mongo/db/structure/catalog/namespace_test.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_test.cpp index 81ed9aa646a..7c50b86a5bf 100644 --- a/src/mongo/db/structure/catalog/namespace_test.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_test.cpp @@ -30,7 +30,7 @@ #include "mongo/unittest/unittest.h" -#include "mongo/db/structure/catalog/namespace.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace.h" namespace mongo { diff --git a/src/mongo/db/storage/mmap_v1/dur_recover.cpp b/src/mongo/db/storage/mmap_v1/dur_recover.cpp index 9d4e679808a..52836e7977f 100644 --- a/src/mongo/db/storage/mmap_v1/dur_recover.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_recover.cpp @@ -40,6 +40,7 @@ #include "mongo/db/catalog/database.h" #include "mongo/db/db.h" #include "mongo/db/storage/storage_engine.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace.h" #include "mongo/db/storage/mmap_v1/dur.h" #include "mongo/db/storage/mmap_v1/dur_commitjob.h" #include "mongo/db/storage/mmap_v1/dur_journal.h" diff --git a/src/mongo/db/storage/mmap_v1/extent.h b/src/mongo/db/storage/mmap_v1/extent.h index 8a27e271c04..f009e283380 100644 --- a/src/mongo/db/storage/mmap_v1/extent.h +++ b/src/mongo/db/storage/mmap_v1/extent.h @@ -34,7 +34,7 @@ #include <vector> #include "mongo/db/diskloc.h" -#include "mongo/db/structure/catalog/namespace.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace.h" namespace mongo { diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp index 303ac49e507..f8ca6265c5f 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp @@ -42,11 +42,12 @@ #include "mongo/db/pdfile_version.h" #include "mongo/db/server_parameters.h" #include "mongo/db/storage/mmap_v1/data_file.h" -#include "mongo/db/structure/catalog/namespace_details.h" -#include "mongo/db/structure/catalog/namespace_details_collection_entry.h" -#include "mongo/db/structure/catalog/namespace_details_rsv1_metadata.h" -#include "mongo/db/structure/record_store_v1_capped.h" -#include "mongo/db/structure/record_store_v1_simple.h" +#include "mongo/db/storage/mmap_v1/btree/btree_interface.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_details.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_details_collection_entry.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_capped.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_simple.h" namespace mongo { @@ -444,7 +445,7 @@ namespace mongo { void MMAPV1DatabaseCatalogEntry::_lazyInit( OperationContext* txn ) { // this is sort of insane - // it's because the whole structure is highly recursive + // it's because the whole storage/mmap_v1 is highly recursive _namespaceIndex.init( txn ); @@ -682,13 +683,13 @@ namespace mongo { rs = entry->recordStore.get(); } - std::auto_ptr<BtreeInterface> btree( - BtreeInterface::getInterface(entry->headManager(), - rs, - entry->ordering(), - entry->descriptor()->indexNamespace(), - entry->descriptor()->version(), - &BtreeBasedAccessMethod::invalidateCursors)); + std::auto_ptr<SortedDataInterface> btree( + getMMAPV1Interface(entry->headManager(), + rs, + entry->ordering(), + entry->descriptor()->indexNamespace(), + entry->descriptor()->version(), + &BtreeBasedAccessMethod::invalidateCursors)); if (IndexNames::HASHED == type) return new HashAccessMethod( entry, btree.release() ); diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.h b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.h index 16a88b84ede..fa5a5874061 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.h +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.h @@ -33,8 +33,8 @@ #include "mongo/base/status.h" #include "mongo/base/string_data.h" #include "mongo/db/catalog/database_catalog_entry.h" +#include "mongo/db/storage/mmap_v1/catalog/namespace_index.h" #include "mongo/db/storage/mmap_v1/mmap_v1_extent_manager.h" -#include "mongo/db/structure/catalog/namespace_index.h" namespace mongo { diff --git a/src/mongo/db/structure/record_store_v1_base.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp index 784a391e204..3a1bed72dd9 100644 --- a/src/mongo/db/structure/record_store_v1_base.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp @@ -28,7 +28,7 @@ * it in the license file. */ -#include "mongo/db/structure/record_store_v1_base.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_base.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/concurrency/lock_mgr.h" @@ -36,7 +36,7 @@ #include "mongo/db/storage/mmap_v1/extent.h" #include "mongo/db/storage/mmap_v1/extent_manager.h" #include "mongo/db/storage/mmap_v1/record.h" -#include "mongo/db/structure/record_store_v1_repair_iterator.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.h" #include "mongo/util/progress_meter.h" #include "mongo/util/timer.h" #include "mongo/util/touch_pages.h" diff --git a/src/mongo/db/structure/record_store_v1_base.h b/src/mongo/db/storage/mmap_v1/record_store_v1_base.h index 7265528762a..72466c2b645 100644 --- a/src/mongo/db/structure/record_store_v1_base.h +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_base.h @@ -31,7 +31,7 @@ #pragma once #include "mongo/db/diskloc.h" -#include "mongo/db/structure/record_store.h" +#include "mongo/db/storage/record_store.h" namespace mongo { diff --git a/src/mongo/db/structure/record_store_v1_capped.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp index fbc6c2e8186..c8524c76e22 100644 --- a/src/mongo/db/structure/record_store_v1_capped.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp @@ -28,13 +28,13 @@ * it in the license file. */ -#include "mongo/db/structure/record_store_v1_capped.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_capped.h" #include "mongo/db/operation_context_impl.h" #include "mongo/db/storage/mmap_v1/extent.h" #include "mongo/db/storage/mmap_v1/extent_manager.h" #include "mongo/db/storage/mmap_v1/record.h" -#include "mongo/db/structure/record_store_v1_capped_iterator.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.h" #include "mongo/util/mmap.h" #include "mongo/util/mongoutils/str.h" diff --git a/src/mongo/db/structure/record_store_v1_capped.h b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.h index 02f28727f30..4422b5d451b 100644 --- a/src/mongo/db/structure/record_store_v1_capped.h +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.h @@ -32,9 +32,9 @@ #include "mongo/base/owned_pointer_vector.h" #include "mongo/db/diskloc.h" +#include "mongo/db/storage/capped_callback.h" #include "mongo/db/storage/mmap_v1/extent_manager.h" -#include "mongo/db/structure/capped_callback.h" -#include "mongo/db/structure/record_store_v1_base.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_base.h" namespace mongo { diff --git a/src/mongo/db/structure/record_store_v1_capped_iterator.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.cpp index c10557d6547..11f7894fe77 100644 --- a/src/mongo/db/structure/record_store_v1_capped_iterator.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.cpp @@ -26,12 +26,12 @@ * it in the license file. */ -#include "mongo/db/structure/record_store_v1_capped_iterator.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/storage/mmap_v1/extent.h" #include "mongo/db/storage/mmap_v1/extent_manager.h" -#include "mongo/db/structure/record_store_v1_capped.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_capped.h" namespace mongo { diff --git a/src/mongo/db/structure/record_store_v1_capped_iterator.h b/src/mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.h index c63d265ec2e..501986d98fa 100644 --- a/src/mongo/db/structure/record_store_v1_capped_iterator.h +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.h @@ -28,7 +28,7 @@ #pragma once -#include "mongo/db/structure/record_store.h" +#include "mongo/db/storage/record_store.h" namespace mongo { diff --git a/src/mongo/db/structure/record_store_v1_capped_test.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_capped_test.cpp index 6ec414ff87d..6e423b9e073 100644 --- a/src/mongo/db/structure/record_store_v1_capped_test.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_capped_test.cpp @@ -28,11 +28,11 @@ * it in the license file. */ -#include "mongo/db/structure/record_store_v1_capped.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_capped.h" #include "mongo/db/operation_context_noop.h" #include "mongo/db/storage/mmap_v1/record.h" -#include "mongo/db/structure/record_store_v1_test_help.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_test_help.h" #include "mongo/unittest/unittest.h" using namespace mongo; diff --git a/src/mongo/db/structure/record_store_v1_repair_iterator.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.cpp index aaa96fa2db8..a210c0dc0f3 100644 --- a/src/mongo/db/structure/record_store_v1_repair_iterator.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.cpp @@ -26,12 +26,12 @@ * it in the license file. */ -#include "mongo/db/structure/record_store_v1_repair_iterator.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/storage/mmap_v1/extent.h" #include "mongo/db/storage/mmap_v1/extent_manager.h" -#include "mongo/db/structure/record_store_v1_simple.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_simple.h" namespace mongo { diff --git a/src/mongo/db/structure/record_store_v1_repair_iterator.h b/src/mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.h index a0319982fda..c75c1c790c1 100644 --- a/src/mongo/db/structure/record_store_v1_repair_iterator.h +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.h @@ -30,8 +30,8 @@ #include <set> -#include "mongo/db/structure/record_store.h" -#include "mongo/db/structure/record_store_v1_base.h" +#include "mongo/db/storage/record_store.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_base.h" namespace mongo { diff --git a/src/mongo/db/structure/record_store_v1_simple.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_simple.cpp index 21dd0d7363e..7a9d17974eb 100644 --- a/src/mongo/db/structure/record_store_v1_simple.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_simple.cpp @@ -30,7 +30,7 @@ #include "mongo/platform/basic.h" -#include "mongo/db/structure/record_store_v1_simple.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_simple.h" #include "mongo/base/counter.h" #include "mongo/db/catalog/collection.h" @@ -40,7 +40,7 @@ #include "mongo/db/storage/mmap_v1/extent_manager.h" #include "mongo/db/storage/mmap_v1/record.h" #include "mongo/db/operation_context.h" -#include "mongo/db/structure/record_store_v1_simple_iterator.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_simple_iterator.h" #include "mongo/util/log.h" #include "mongo/util/progress_meter.h" #include "mongo/util/timer.h" diff --git a/src/mongo/db/structure/record_store_v1_simple.h b/src/mongo/db/storage/mmap_v1/record_store_v1_simple.h index 786be3c8056..abc6b11b928 100644 --- a/src/mongo/db/structure/record_store_v1_simple.h +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_simple.h @@ -31,7 +31,7 @@ #pragma once #include "mongo/db/diskloc.h" -#include "mongo/db/structure/record_store_v1_base.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_base.h" namespace mongo { diff --git a/src/mongo/db/structure/record_store_v1_simple_iterator.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_simple_iterator.cpp index 675042d3948..803b1494920 100644 --- a/src/mongo/db/structure/record_store_v1_simple_iterator.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_simple_iterator.cpp @@ -26,12 +26,12 @@ * it in the license file. */ -#include "mongo/db/structure/record_store_v1_simple_iterator.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_simple_iterator.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/storage/mmap_v1/extent.h" #include "mongo/db/storage/mmap_v1/extent_manager.h" -#include "mongo/db/structure/record_store_v1_simple.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_simple.h" namespace mongo { diff --git a/src/mongo/db/structure/record_store_v1_simple_iterator.h b/src/mongo/db/storage/mmap_v1/record_store_v1_simple_iterator.h index 7688b15be85..ded30a3ee1d 100644 --- a/src/mongo/db/structure/record_store_v1_simple_iterator.h +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_simple_iterator.h @@ -28,7 +28,7 @@ #pragma once -#include "mongo/db/structure/record_store.h" +#include "mongo/db/storage/record_store.h" namespace mongo { diff --git a/src/mongo/db/structure/record_store_v1_simple_test.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_simple_test.cpp index 4788e46b1cf..31f17f42b28 100644 --- a/src/mongo/db/structure/record_store_v1_simple_test.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_simple_test.cpp @@ -28,11 +28,11 @@ * it in the license file. */ -#include "mongo/db/structure/record_store_v1_simple.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_simple.h" #include "mongo/db/operation_context_noop.h" #include "mongo/db/storage/mmap_v1/record.h" -#include "mongo/db/structure/record_store_v1_test_help.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_test_help.h" #include "mongo/unittest/unittest.h" using namespace mongo; diff --git a/src/mongo/db/structure/record_store_v1_test_help.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp index fb25786d54d..3ea4298332f 100644 --- a/src/mongo/db/structure/record_store_v1_test_help.cpp +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp @@ -28,7 +28,7 @@ * it in the license file. */ -#include "mongo/db/structure/record_store_v1_test_help.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_test_help.h" #include <algorithm> #include <map> diff --git a/src/mongo/db/structure/record_store_v1_test_help.h b/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.h index 75c62205b72..87ddc078b6d 100644 --- a/src/mongo/db/structure/record_store_v1_test_help.h +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.h @@ -33,7 +33,7 @@ #include <vector> #include "mongo/db/storage/mmap_v1/extent_manager.h" -#include "mongo/db/structure/record_store_v1_base.h" +#include "mongo/db/storage/mmap_v1/record_store_v1_base.h" namespace mongo { @@ -158,7 +158,7 @@ namespace mongo { }; /** - * Creates a V1 structure with the passed in records and DeletedRecords (drecs). + * Creates a V1 storage/mmap_v1 with the passed in records and DeletedRecords (drecs). * * List of LocAndSize are terminated by a Null DiskLoc. Passing a NULL pointer is shorthand for * an empty list. Each extent gets it's own DiskLoc file number. DiskLoc Offsets must be > 1000. diff --git a/src/mongo/db/structure/record_store.h b/src/mongo/db/storage/record_store.h index 1d6ca0098b0..8437046e5d6 100644 --- a/src/mongo/db/structure/record_store.h +++ b/src/mongo/db/storage/record_store.h @@ -114,8 +114,9 @@ namespace mongo { class RecordStore { MONGO_DISALLOW_COPYING(RecordStore); public: - RecordStore( const StringData& ns ); - virtual ~RecordStore(); + RecordStore( const StringData& ns ) : _ns(ns.toString()) { } + + virtual ~RecordStore() { } // META diff --git a/src/mongo/db/storage/rocks/rocks_btree_impl.cpp b/src/mongo/db/storage/rocks/rocks_btree_impl.cpp index 00cbbf1c580..8bd3f2734cf 100644 --- a/src/mongo/db/storage/rocks/rocks_btree_impl.cpp +++ b/src/mongo/db/storage/rocks/rocks_btree_impl.cpp @@ -87,7 +87,7 @@ namespace mongo { rocksdb::Slice sliced[2]; }; - class RocksCursor : public BtreeInterface::Cursor { + class RocksCursor : public SortedDataInterface::Cursor { public: RocksCursor( rocksdb::Iterator* iterator, bool direction ) : _iterator( iterator ), _direction( direction ), _cached( false ) { @@ -285,8 +285,8 @@ namespace mongo { return Status::OK(); } - BtreeInterface::Cursor* RocksBtreeImpl::newCursor(OperationContext* txn, - int direction) const { + SortedDataInterface::Cursor* RocksBtreeImpl::newCursor(OperationContext* txn, + int direction) const { return new RocksCursor( _db->NewIterator( rocksdb::ReadOptions(), _columnFamily ), txn, diff --git a/src/mongo/db/storage/rocks/rocks_btree_impl.h b/src/mongo/db/storage/rocks/rocks_btree_impl.h index 2a15e46aad5..4e75ad50e11 100644 --- a/src/mongo/db/storage/rocks/rocks_btree_impl.h +++ b/src/mongo/db/storage/rocks/rocks_btree_impl.h @@ -28,7 +28,7 @@ * it in the license file. */ -#include "mongo/db/structure/btree/btree_interface.h" +#include "mongo/db/storage/sorted_data_interface.h" #pragma once @@ -47,7 +47,7 @@ namespace mongo { virtual unsigned long long commit(bool mayInterrupt) = 0; }; - class RocksBtreeImpl : public BtreeInterface { + class RocksBtreeImpl : public SortedDataInterface { public: RocksBtreeImpl( rocksdb::DB* db, rocksdb::ColumnFamilyHandle* cf ); diff --git a/src/mongo/db/storage/rocks/rocks_btree_impl_test.cpp b/src/mongo/db/storage/rocks/rocks_btree_impl_test.cpp index f7102163352..e080fb08faf 100644 --- a/src/mongo/db/storage/rocks/rocks_btree_impl_test.cpp +++ b/src/mongo/db/storage/rocks/rocks_btree_impl_test.cpp @@ -126,7 +126,7 @@ namespace mongo { DiskLoc loc( 5, 16 ); { - scoped_ptr<BtreeInterface::Cursor> cursor( btree.newCursor( 1 ) ); + scoped_ptr<SortedDataInterface::Cursor> cursor( btree.newCursor( 1 ) ); ASSERT( !cursor->locate( key, loc ) ); } @@ -140,7 +140,7 @@ namespace mongo { } { - scoped_ptr<BtreeInterface::Cursor> cursor( btree.newCursor( 1 ) ); + scoped_ptr<SortedDataInterface::Cursor> cursor( btree.newCursor( 1 ) ); ASSERT( cursor->locate( key, loc ) ); ASSERT_EQUALS( key, cursor->getKey() ); ASSERT_EQUALS( loc, cursor->getDiskLoc() ); @@ -166,7 +166,7 @@ namespace mongo { } { - scoped_ptr<BtreeInterface::Cursor> cursor( btree.newCursor( 1 ) ); + scoped_ptr<SortedDataInterface::Cursor> cursor( btree.newCursor( 1 ) ); ASSERT( cursor->locate( BSON( "a" << 2 ), DiskLoc(0,0) ) ); ASSERT( !cursor->isEOF() ); ASSERT_EQUALS( BSON( "" << 2 ), cursor->getKey() ); diff --git a/src/mongo/db/structure/btree/btree_interface.h b/src/mongo/db/storage/sorted_data_interface.h index 845a02d467a..52f20a6288d 100644 --- a/src/mongo/db/structure/btree/btree_interface.h +++ b/src/mongo/db/storage/sorted_data_interface.h @@ -27,64 +27,39 @@ */ #include "mongo/bson/ordering.h" +#include "mongo/db/catalog/head_manager.h" #include "mongo/db/diskloc.h" #include "mongo/db/jsobj.h" #include "mongo/db/operation_context.h" -#include "mongo/db/structure/head_manager.h" -#include "mongo/db/structure/record_store.h" +#include "mongo/db/storage/record_store.h" #pragma once namespace mongo { class BucketDeletionNotification; + class SortedDataBuilderInterface; /** - * A version-hiding wrapper around the bulk builder for the Btree. + * This interface is a work in progress. Notes below: + * + * This interface began as the SortedDataInterface, a way to hide the fact that there were two + * on-disk formats for the btree. With the introduction of other storage engines, this + * interface was generalized to provide access to sorted data. Specifically: + * + * 1. Many other storage engines provide different Btree(-ish) implementations. This interface + * could allow those interfaces to avoid storing btree buckets in an already sorted structure. + * + * TODO: See if there is actually a performance gain. + * + * 2. The existing btree implementation is written to assume that if it modifies a record it is + * modifying the underlying record. This interface is an attempt to work around that. + * + * TODO: See if this actually works. */ - class BtreeBuilderInterface { + class SortedDataInterface { public: - virtual ~BtreeBuilderInterface() { } - - /** - * Adds 'key' to intermediate storage. - * - * 'key' must be > or >= the last key passed to this function (depends on _dupsAllowed). If - * this is violated an error Status (ErrorCodes::InternalError) will be returned. - */ - virtual Status addKey(const BSONObj& key, const DiskLoc& loc) = 0; - - /** - * commit work. if not called, destructor will clean up partially completed work - * (in case exception has happened). - * - * Returns number of keys added. - */ - virtual unsigned long long commit(bool mayInterrupt) = 0; - }; - - /** - * This is the interface for interacting with the Btree. The index access and catalog layers - * should use this. - */ - class BtreeInterface { - public: - - virtual ~BtreeInterface() { } - - /** - * Interact with the Btree through the BtreeInterface. - * - * Does not own headManager. - * Does not own recordStore. - * Copies ordering. - */ - static BtreeInterface* getInterface(HeadManager* headManager, - RecordStore* recordStore, - const Ordering& ordering, - const string& indexName, - int version, - BucketDeletionNotification* bucketDeletion); + virtual ~SortedDataInterface() { } // // Data changes @@ -94,8 +69,8 @@ namespace mongo { * Caller owns returned pointer. * 'this' must outlive the returned pointer. */ - virtual BtreeBuilderInterface* getBulkBuilder(OperationContext* txn, - bool dupsAllowed) = 0; + virtual SortedDataBuilderInterface* getBulkBuilder(OperationContext* txn, + bool dupsAllowed) = 0; virtual Status insert(OperationContext* txn, const BSONObj& key, @@ -144,8 +119,8 @@ namespace mongo { virtual bool pointsToSamePlaceAs(const Cursor& other) const = 0; /** - * If the BtreeInterface impl calls the BucketNotificationCallback, the argument must - * be forwarded to all Cursors over that Btree. + * If the SortedDataInterface impl calls the BucketNotificationCallback, the argument must + * be forwarded to all Cursors over that SortedData. * TODO something better. */ virtual void aboutToDeleteBucket(const DiskLoc& bucket) = 0; @@ -187,7 +162,7 @@ namespace mongo { }; /** - * Caller takes ownership. BtreeInterface must outlive all Cursors it produces. + * Caller takes ownership. SortedDataInterface must outlive all Cursors it produces. */ virtual Cursor* newCursor(OperationContext* txn, int direction) const = 0; @@ -198,4 +173,28 @@ namespace mongo { virtual Status initAsEmpty(OperationContext* txn) = 0; }; + /** + * A version-hiding wrapper around the bulk builder for the Btree. + */ + class SortedDataBuilderInterface { + public: + virtual ~SortedDataBuilderInterface() { } + + /** + * Adds 'key' to intermediate storage. + * + * 'key' must be > or >= the last key passed to this function (depends on _dupsAllowed). If + * this is violated an error Status (ErrorCodes::InternalError) will be returned. + */ + virtual Status addKey(const BSONObj& key, const DiskLoc& loc) = 0; + + /** + * commit work. if not called, destructor will clean up partially completed work + * (in case exception has happened). + * + * Returns number of keys added. + */ + virtual unsigned long long commit(bool mayInterrupt) = 0; + }; + } // namespace mongo diff --git a/src/mongo/db/structure/SConscript b/src/mongo/db/structure/SConscript deleted file mode 100644 index f6163c4aaf4..00000000000 --- a/src/mongo/db/structure/SConscript +++ /dev/null @@ -1,60 +0,0 @@ - -Import("env") - -env.Library( - target= 'record_store', - source= [ - 'record_store.cpp', - 'record_store_heap.cpp', - ], - LIBDEPS= [ - '$BUILD_DIR/mongo/bson', - '$BUILD_DIR/mongo/db/commands/server_status_core', - '$BUILD_DIR/mongo/db/concurrency/lock_mgr', - '$BUILD_DIR/mongo/foundation', - '$BUILD_DIR/mongo/mongocommon', - ] - ) - -env.Library( - target= 'record_store_v1', - source= [ - 'record_store_v1_base.cpp', - 'record_store_v1_capped.cpp', - 'record_store_v1_capped_iterator.cpp', - 'record_store_v1_repair_iterator.cpp', - 'record_store_v1_simple.cpp', - 'record_store_v1_simple_iterator.cpp', - ], - LIBDEPS= [ - 'record_store', - '$BUILD_DIR/mongo/db/storage/mmap_v1/extent', - ] - ) - -env.Library( - target='record_store_v1_test_help', - source=['record_store_v1_test_help.cpp', - ], - LIBDEPS=[ - 'record_store_v1' - ] - ) - -env.CppUnitTest( - target='record_store_v1_simple_test', - source=['record_store_v1_simple_test.cpp', - ], - LIBDEPS=[ - 'record_store_v1_test_help' - ] - ) - -env.CppUnitTest( - target='record_store_v1_capped_test', - source=['record_store_v1_capped_test.cpp', - ], - LIBDEPS=[ - 'record_store_v1_test_help' - ] - ) diff --git a/src/mongo/db/structure/btree/SConscript b/src/mongo/db/structure/btree/SConscript deleted file mode 100644 index ffb4003875f..00000000000 --- a/src/mongo/db/structure/btree/SConscript +++ /dev/null @@ -1,44 +0,0 @@ -# -*- mode: python -*- - -Import("env") - -env.Library( - target= 'btree', - source= [ - 'btree_logic.cpp', - 'btree_interface.cpp', - 'key.cpp' - ], - LIBDEPS= [ - '$BUILD_DIR/mongo/bson' - ] - ) - -env.Library( - target= 'btree_test_help', - source= [ - 'btree_test_help.cpp' - ], - LIBDEPS= [ - 'btree', - '$BUILD_DIR/mongo/db/structure/record_store_v1_test_help' - ] - ) - -env.CppUnitTest( - target='btree_logic_test', - source=['btree_logic_test.cpp' - ], - LIBDEPS=[ - 'btree_test_help' - ] - ) - -env.CppUnitTest( - target='btree_builder_test', - source=['btree_builder_test.cpp' - ], - LIBDEPS=[ - 'btree_test_help' - ] - ) |