diff options
author | Eliot Horowitz <eliot@10gen.com> | 2014-05-19 16:05:41 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2014-05-19 16:05:41 -0400 |
commit | db0e1a91fdce2fa43584408a87d637cfe4bcc2ec (patch) | |
tree | 8cbefae4f2f43f41f4a512f5b8f250b1662dfbbf /src/mongo/db/index | |
parent | f2bfd36a6f3eb7e7e2587268be3cc12636703d42 (diff) | |
download | mongo-db0e1a91fdce2fa43584408a87d637cfe4bcc2ec.tar.gz |
SERVER-13637: add CollectionCatalogEntry, start Database layer
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r-- | src/mongo/db/index/2d_access_method.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/index/2d_access_method.h | 3 | ||||
-rw-r--r-- | src/mongo/db/index/btree_access_method.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/index/btree_access_method.h | 3 | ||||
-rw-r--r-- | src/mongo/db/index/btree_based_access_method.cpp | 25 | ||||
-rw-r--r-- | src/mongo/db/index/btree_based_access_method.h | 14 | ||||
-rw-r--r-- | src/mongo/db/index/btree_based_bulk_access_method.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/index/btree_based_bulk_access_method.h | 2 | ||||
-rw-r--r-- | src/mongo/db/index/fts_access_method.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/index/fts_access_method.h | 2 | ||||
-rw-r--r-- | src/mongo/db/index/hash_access_method.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/index/hash_access_method.h | 2 | ||||
-rw-r--r-- | src/mongo/db/index/haystack_access_method.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/index/haystack_access_method.h | 7 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.h | 2 | ||||
-rw-r--r-- | src/mongo/db/index/s2_access_method.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/index/s2_access_method.h | 2 |
17 files changed, 50 insertions, 46 deletions
diff --git a/src/mongo/db/index/2d_access_method.cpp b/src/mongo/db/index/2d_access_method.cpp index 7a5cbc9ff0b..8823c3a08c9 100644 --- a/src/mongo/db/index/2d_access_method.cpp +++ b/src/mongo/db/index/2d_access_method.cpp @@ -41,8 +41,9 @@ namespace mongo { - TwoDAccessMethod::TwoDAccessMethod(IndexCatalogEntry* btreeState) - : BtreeBasedAccessMethod(btreeState) { + TwoDAccessMethod::TwoDAccessMethod(IndexCatalogEntry* btreeState, + RecordStore* rs) + : BtreeBasedAccessMethod(btreeState, rs) { 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 e7796ea0b4d..2f8eea41959 100644 --- a/src/mongo/db/index/2d_access_method.h +++ b/src/mongo/db/index/2d_access_method.h @@ -68,7 +68,8 @@ namespace mongo { public: using BtreeBasedAccessMethod::_descriptor; - TwoDAccessMethod(IndexCatalogEntry* btreeState); + TwoDAccessMethod(IndexCatalogEntry* btreeState, + RecordStore* rs); virtual ~TwoDAccessMethod() { } private: diff --git a/src/mongo/db/index/btree_access_method.cpp b/src/mongo/db/index/btree_access_method.cpp index 91a76c42f82..f9baf4e94d0 100644 --- a/src/mongo/db/index/btree_access_method.cpp +++ b/src/mongo/db/index/btree_access_method.cpp @@ -40,8 +40,8 @@ namespace mongo { // Standard Btree implementation below. - BtreeAccessMethod::BtreeAccessMethod(IndexCatalogEntry* btreeState) - : BtreeBasedAccessMethod(btreeState) { + BtreeAccessMethod::BtreeAccessMethod(IndexCatalogEntry* btreeState, RecordStore* rs ) + : BtreeBasedAccessMethod(btreeState, rs) { // The key generation wants these values. vector<const char*> fieldNames; diff --git a/src/mongo/db/index/btree_access_method.h b/src/mongo/db/index/btree_access_method.h index d40bc013767..74c4cdfc997 100644 --- a/src/mongo/db/index/btree_access_method.h +++ b/src/mongo/db/index/btree_access_method.h @@ -51,7 +51,8 @@ namespace mongo { // superclass and subclasses (like this) can use them. using BtreeBasedAccessMethod::_descriptor; - BtreeAccessMethod(IndexCatalogEntry* btreeState ); + BtreeAccessMethod(IndexCatalogEntry* btreeState, + RecordStore* rs ); 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 6d16f375dc0..8258c23f347 100644 --- a/src/mongo/db/index/btree_based_access_method.cpp +++ b/src/mongo/db/index/btree_based_access_method.cpp @@ -41,8 +41,6 @@ #include "mongo/db/kill_current_op.h" #include "mongo/db/pdfile.h" #include "mongo/db/pdfile_private.h" -#include "mongo/db/repl/is_master.h" -#include "mongo/db/repl/rs.h" #include "mongo/db/server_parameters.h" #include "mongo/db/operation_context.h" #include "mongo/db/structure/btree/btree_interface.h" @@ -66,12 +64,15 @@ namespace mongo { static InvalidateCursorsNotification invalidateCursors; - BtreeBasedAccessMethod::BtreeBasedAccessMethod(IndexCatalogEntry* btreeState) - : _btreeState(btreeState), _descriptor(btreeState->descriptor()) { + BtreeBasedAccessMethod::BtreeBasedAccessMethod(IndexCatalogEntry* btreeState, + RecordStore* recordStore) + : _btreeState(btreeState), + _recordStore( recordStore ), + _descriptor(btreeState->descriptor()) { verify(0 == _descriptor->version() || 1 == _descriptor->version()); _newInterface.reset(BtreeInterface::getInterface(btreeState->headManager(), - btreeState->recordStore(), + recordStore, btreeState->ordering(), _descriptor->indexNamespace(), _descriptor->version(), @@ -104,7 +105,7 @@ namespace mongo { if (ErrorCodes::KeyTooLong == status.code()) { // Ignore this error if we're on a secondary. - if (!isMasterNs(collection()->ns().ns().c_str())) { + if (!txn->isPrimaryFor(_btreeState->ns())) { continue; } @@ -149,7 +150,6 @@ namespace mongo { problem() << "Assertion failure: _unindex failed " << _descriptor->indexNamespace() << endl; out() << "Assertion failure: _unindex failed: " << e.what() << '\n'; - out() << " obj:" << _btreeState->collection()->docFor(loc).toString() << '\n'; out() << " key:" << key.toString() << '\n'; out() << " dl:" << loc.toString() << endl; logContext(); @@ -182,8 +182,7 @@ namespace mongo { ++*numDeleted; } else if (options.logIfError) { log() << "unindex failed (key too big?) " << _descriptor->indexNamespace() - << " key: " << *i << " " - << _btreeState->collection()->docFor(loc)["_id"] << endl; + << " key: " << *i; } } @@ -227,8 +226,9 @@ namespace mongo { return Status::OK(); } + Status BtreeBasedAccessMethod::touch( OperationContext* txn ) const { - return _btreeState->recordStore()->touch( txn, NULL ); + return _recordStore->touch( txn, NULL ); } DiskLoc BtreeBasedAccessMethod::findSingle(const BSONObj& key) const { @@ -323,7 +323,8 @@ namespace mongo { return Status::OK(); } - IndexAccessMethod* BtreeBasedAccessMethod::initiateBulk(OperationContext* txn) { + IndexAccessMethod* BtreeBasedAccessMethod::initiateBulk(OperationContext* txn, + int64_t numRecords ) { // If there's already data in the index, don't do anything. if (!_newInterface->isEmpty()) { return NULL; @@ -333,7 +334,7 @@ namespace mongo { this, _newInterface.get(), _descriptor, - _btreeState->collection()->numRecords()); + static_cast<int>( numRecords ) ); } Status BtreeBasedAccessMethod::commitBulk(IndexAccessMethod* bulkRaw, diff --git a/src/mongo/db/index/btree_based_access_method.h b/src/mongo/db/index/btree_based_access_method.h index decfbb0bc9a..c54c71d401f 100644 --- a/src/mongo/db/index/btree_based_access_method.h +++ b/src/mongo/db/index/btree_based_access_method.h @@ -41,6 +41,7 @@ namespace mongo { class ExternalSortComparison; + class RecordStore; /** * Any access method that is Btree based subclasses from this. @@ -56,7 +57,8 @@ namespace mongo { class BtreeBasedAccessMethod : public IndexAccessMethod { MONGO_DISALLOW_COPYING( BtreeBasedAccessMethod ); public: - BtreeBasedAccessMethod( IndexCatalogEntry* btreeState ); + BtreeBasedAccessMethod( IndexCatalogEntry* btreeState, + RecordStore* recordStore ); virtual ~BtreeBasedAccessMethod() { } @@ -86,7 +88,7 @@ namespace mongo { virtual Status initializeAsEmpty(OperationContext* txn); - virtual IndexAccessMethod* initiateBulk(OperationContext* txn) ; + virtual IndexAccessMethod* initiateBulk(OperationContext* txn, int64_t numRecords ); virtual Status commitBulk( IndexAccessMethod* bulk, bool mayInterrupt, @@ -111,15 +113,9 @@ namespace mongo { virtual void getKeys(const BSONObj &obj, BSONObjSet *keys) = 0; IndexCatalogEntry* _btreeState; // owned by IndexCatalogEntry + scoped_ptr<RecordStore> _recordStore; // owned by us const IndexDescriptor* _descriptor; - /** - * The collection is needed for resolving record locations to actual objects. - */ - const Collection* collection() const { - return _btreeState->collection(); - } - private: bool removeOneKey(OperationContext* txn, const BSONObj& key, 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 5d2f0906564..ca6e6022d53 100644 --- a/src/mongo/db/index/btree_based_bulk_access_method.cpp +++ b/src/mongo/db/index/btree_based_bulk_access_method.cpp @@ -141,7 +141,7 @@ namespace mongo { // XXX: do we expect the tree to be empty but have a head set? Looks like so from old code. invariant(!oldHead.isNull()); _real->_btreeState->setHead(_txn, DiskLoc()); - _real->_btreeState->recordStore()->deleteRecord(_txn, oldHead); + _real->_recordStore->deleteRecord(_txn, oldHead); if (_isMultiKey) { _real->_btreeState->setMultikey( _txn ); 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 cedf1eedf80..856a1c3b1de 100644 --- a/src/mongo/db/index/btree_based_bulk_access_method.h +++ b/src/mongo/db/index/btree_based_bulk_access_method.h @@ -119,7 +119,7 @@ namespace mongo { return _notAllowed(); } - virtual IndexAccessMethod* initiateBulk(OperationContext* txn) { + virtual IndexAccessMethod* initiateBulk(OperationContext* txn, int64_t numRecords ) { return NULL; } diff --git a/src/mongo/db/index/fts_access_method.cpp b/src/mongo/db/index/fts_access_method.cpp index c803867b812..5eb20d4f8cf 100644 --- a/src/mongo/db/index/fts_access_method.cpp +++ b/src/mongo/db/index/fts_access_method.cpp @@ -31,8 +31,8 @@ namespace mongo { - FTSAccessMethod::FTSAccessMethod(IndexCatalogEntry* btreeState) - : BtreeBasedAccessMethod(btreeState), _ftsSpec(btreeState->descriptor()->infoObj()) { } + FTSAccessMethod::FTSAccessMethod(IndexCatalogEntry* btreeState, RecordStore* rs ) + : BtreeBasedAccessMethod(btreeState, rs), _ftsSpec(btreeState->descriptor()->infoObj()) { } void FTSAccessMethod::getKeys(const BSONObj& obj, BSONObjSet* keys) { ExpressionKeysPrivate::getFTSKeys(obj, _ftsSpec, keys); diff --git a/src/mongo/db/index/fts_access_method.h b/src/mongo/db/index/fts_access_method.h index ba10b4e2b67..2ea4fecc375 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 ); + FTSAccessMethod(IndexCatalogEntry* btreeState, RecordStore* rs ); 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 7457c68c085..bb3684c020a 100644 --- a/src/mongo/db/index/hash_access_method.cpp +++ b/src/mongo/db/index/hash_access_method.cpp @@ -33,8 +33,8 @@ namespace mongo { - HashAccessMethod::HashAccessMethod(IndexCatalogEntry* btreeState) - : BtreeBasedAccessMethod(btreeState) { + HashAccessMethod::HashAccessMethod(IndexCatalogEntry* btreeState, RecordStore* rs) + : BtreeBasedAccessMethod(btreeState, rs) { 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 e6e701158ce..0b6777a16da 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); + HashAccessMethod(IndexCatalogEntry* btreeState, RecordStore* rs); virtual ~HashAccessMethod() { } // This is a NO-OP. diff --git a/src/mongo/db/index/haystack_access_method.cpp b/src/mongo/db/index/haystack_access_method.cpp index 59e97a6191c..9bf1ee6593b 100644 --- a/src/mongo/db/index/haystack_access_method.cpp +++ b/src/mongo/db/index/haystack_access_method.cpp @@ -39,8 +39,8 @@ namespace mongo { - HaystackAccessMethod::HaystackAccessMethod(IndexCatalogEntry* btreeState) - : BtreeBasedAccessMethod(btreeState) { + HaystackAccessMethod::HaystackAccessMethod(IndexCatalogEntry* btreeState, RecordStore* rs) + : BtreeBasedAccessMethod(btreeState, rs) { const IndexDescriptor* descriptor = btreeState->descriptor(); @@ -57,7 +57,8 @@ namespace mongo { ExpressionKeysPrivate::getHaystackKeys(obj, _geoField, _otherFields, _bucketSize, keys); } - void HaystackAccessMethod::searchCommand(const BSONObj& nearObj, double maxDistance, + void HaystackAccessMethod::searchCommand(Collection* collection, + const BSONObj& nearObj, double maxDistance, const BSONObj& search, BSONObjBuilder* result, unsigned limit) { Timer t; @@ -72,7 +73,7 @@ namespace mongo { } int scale = static_cast<int>(ceil(maxDistance / _bucketSize)); - GeoHaystackSearchHopper hopper(nearObj, maxDistance, limit, _geoField, collection()); + GeoHaystackSearchHopper hopper(nearObj, maxDistance, limit, _geoField, collection); long long btreeMatches = 0; @@ -95,7 +96,7 @@ namespace mongo { unordered_set<DiskLoc, DiskLoc::Hasher> thisPass; - scoped_ptr<Runner> runner(InternalPlanner::indexScan(_btreeState->collection(), + scoped_ptr<Runner> runner(InternalPlanner::indexScan(collection, _descriptor, key, key, true)); Runner::RunnerState state; DiskLoc loc; diff --git a/src/mongo/db/index/haystack_access_method.h b/src/mongo/db/index/haystack_access_method.h index 82d8eccf6ef..e1a4fe9e7df 100644 --- a/src/mongo/db/index/haystack_access_method.h +++ b/src/mongo/db/index/haystack_access_method.h @@ -35,6 +35,8 @@ namespace mongo { + class Collection; + /** * Maps (lat, lng) to the bucketSize-sided square bucket that contains it. * Examines all documents in a given radius of a given point. @@ -55,12 +57,13 @@ namespace mongo { public: using BtreeBasedAccessMethod::_descriptor; - HaystackAccessMethod(IndexCatalogEntry* btreeState); + HaystackAccessMethod(IndexCatalogEntry* btreeState, RecordStore* rs); virtual ~HaystackAccessMethod() { } protected: friend class GeoHaystackSearchCommand; - void searchCommand(const BSONObj& nearObj, double maxDistance, const BSONObj& search, + void searchCommand(Collection* collection, + const BSONObj& nearObj, double maxDistance, const BSONObj& search, BSONObjBuilder* result, unsigned limit); private: diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h index 6268ad0cb90..efdc59384aa 100644 --- a/src/mongo/db/index/index_access_method.h +++ b/src/mongo/db/index/index_access_method.h @@ -168,7 +168,7 @@ namespace mongo { * For now (1/8/14) you can only do bulk when the index is empty * it will fail if you try other times. */ - virtual IndexAccessMethod* initiateBulk(OperationContext* txn) = 0; + virtual IndexAccessMethod* initiateBulk(OperationContext* txn, int64_t numRecords ) = 0; /** * Call this when you are ready to finish your bulk work. diff --git a/src/mongo/db/index/s2_access_method.cpp b/src/mongo/db/index/s2_access_method.cpp index 9cbfd2d418b..c75ec66d44e 100644 --- a/src/mongo/db/index/s2_access_method.cpp +++ b/src/mongo/db/index/s2_access_method.cpp @@ -43,8 +43,8 @@ namespace mongo { static const string kIndexVersionFieldName("2dsphereIndexVersion"); - S2AccessMethod::S2AccessMethod(IndexCatalogEntry* btreeState) - : BtreeBasedAccessMethod(btreeState) { + S2AccessMethod::S2AccessMethod(IndexCatalogEntry* btreeState, RecordStore* rs) + : BtreeBasedAccessMethod(btreeState, rs) { 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 df12026395b..666d2bb1e98 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); + S2AccessMethod(IndexCatalogEntry* btreeState, RecordStore* rs); virtual ~S2AccessMethod() { } /** |