summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-04-28 17:28:02 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-04-29 15:09:57 -0400
commitca3f2b297817fc6f1a535bd0281df7ecc3ba6979 (patch)
tree71ffefdce2d682b02102c6de68906c4fbcf1aa83 /src/mongo
parentcf3d1dd725362dd098af038f99f7fb232e3210b3 (diff)
downloadmongo-ca3f2b297817fc6f1a535bd0281df7ecc3ba6979.tar.gz
SERVER-13084,SERVER-13632,SERVER-13634 Remove DiskLoc methods hitting disk
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/catalog/database.cpp12
-rw-r--r--src/mongo/db/catalog/index_catalog.cpp23
-rw-r--r--src/mongo/db/catalog/index_catalog_entry.cpp4
-rw-r--r--src/mongo/db/catalog/index_catalog_entry.h4
-rw-r--r--src/mongo/db/commands/rename_collection.cpp6
-rw-r--r--src/mongo/db/dbhelpers.cpp7
-rw-r--r--src/mongo/db/dbhelpers.h10
-rw-r--r--src/mongo/db/diskloc.h8
-rw-r--r--src/mongo/db/storage/record.cpp10
-rw-r--r--src/mongo/db/structure/catalog/namespace_details.cpp6
-rw-r--r--src/mongo/db/structure/catalog/namespace_details.h16
-rw-r--r--src/mongo/dbtests/dbhelper_tests.cpp13
-rw-r--r--src/mongo/dbtests/indexupdatetests.cpp16
-rw-r--r--src/mongo/dbtests/query_stage_and.cpp16
-rw-r--r--src/mongo/dbtests/query_stage_collscan.cpp16
-rw-r--r--src/mongo/dbtests/query_stage_fetch.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_sort.cpp2
-rw-r--r--src/mongo/dbtests/querytests.cpp8
-rw-r--r--src/mongo/dbtests/queryutiltests.cpp2
-rw-r--r--src/mongo/dbtests/repltests.cpp4
-rw-r--r--src/mongo/s/d_split.cpp2
21 files changed, 90 insertions, 97 deletions
diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp
index 1c59bf5e363..fad88e98c20 100644
--- a/src/mongo/db/catalog/database.cpp
+++ b/src/mongo/db/catalog/database.cpp
@@ -519,11 +519,11 @@ namespace mongo {
audit::logRenameCollection( currentClient.get(), fromNS, toNS );
+ Collection* systemIndexCollection = getCollection(txn, _indexesName);
+
// move index namespaces
BSONObj oldIndexSpec;
- while( Helpers::findOne( getCollection( txn, _indexesName ),
- BSON( "ns" << fromNS ),
- oldIndexSpec ) ) {
+ while (Helpers::findOne(systemIndexCollection, BSON("ns" << fromNS), oldIndexSpec)) {
oldIndexSpec = oldIndexSpec.getOwned();
BSONObj newIndexSpec;
@@ -540,8 +540,6 @@ namespace mongo {
newIndexSpec = b.obj();
}
- Collection* systemIndexCollection = getCollection( txn, _indexesName );
-
StatusWith<DiskLoc> newIndexSpecLoc =
systemIndexCollection->insertDocument( txn, newIndexSpec, false );
if ( !newIndexSpecLoc.isOK() )
@@ -551,7 +549,9 @@ namespace mongo {
{
// fix IndexDetails pointer
- int indexI = details->_catalogFindIndexByName( indexName );
+ int indexI = details->_catalogFindIndexByName(
+ systemIndexCollection, indexName, false);
+
IndexDetails& indexDetails = details->idx(indexI);
*txn->writing(&indexDetails.info) = newIndexSpecLoc.getValue(); // XXX: dur
}
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp
index ad2aac97b77..70103890a05 100644
--- a/src/mongo/db/catalog/index_catalog.cpp
+++ b/src/mongo/db/catalog/index_catalog.cpp
@@ -100,11 +100,11 @@ namespace mongo {
int idxNo = ii.pos() - 1;
if ( idxNo >= _details->getCompletedIndexCount() ) {
- _unfinishedIndexes.push_back( id.info.obj().getOwned() );
+ _unfinishedIndexes.push_back(_collection->docFor(id.info).getOwned());
continue;
}
- BSONObj ownedInfoObj = id.info.obj().getOwned();
+ BSONObj ownedInfoObj = _collection->docFor(id.info).getOwned();
BSONObj keyPattern = ownedInfoObj.getObjectField("key");
IndexDescriptor* descriptor = new IndexDescriptor( _collection,
_getAccessMethodName(keyPattern),
@@ -343,7 +343,7 @@ namespace mongo {
string idxName = descriptor->indexName(); // out copy for yields, etc...
invariant( entry == _entries.find( descriptor ) );
- invariant( _details->_catalogFindIndexByName( idxName, true ) >= 0 );
+ invariant(_details->_catalogFindIndexByName(_collection, idxName, true) >= 0);
try {
Client& client = cc();
@@ -361,7 +361,7 @@ namespace mongo {
_inProgressIndexes.erase(it);
// sanity check
- int idxNo = _details->_catalogFindIndexByName( idxName, true );
+ int idxNo = _details->_catalogFindIndexByName(_collection, idxName, true);
invariant( idxNo < numIndexesReady() );
return Status::OK();
@@ -508,7 +508,7 @@ namespace mongo {
_inProgress = false; // defensive
fassert( 17204, _catalog->_collection->ok() ); // defensive
- int idxNo = _collection->details()->_catalogFindIndexByName( _indexName, true );
+ int idxNo = _collection->details()->_catalogFindIndexByName(_collection, _indexName, true);
fassert( 17205, idxNo >= 0 );
IndexCatalogEntry* entry = _catalog->_entries.find( _indexName );
@@ -538,7 +538,7 @@ namespace mongo {
NamespaceDetails* nsd = _collection->detailsWritable();
- int idxNo = nsd->_catalogFindIndexByName( _indexName, true );
+ int idxNo = nsd->_catalogFindIndexByName(_collection, _indexName, true);
fassert( 17202, idxNo >= 0 );
// Make sure the newly created index is relocated to nIndexes, if it isn't already there
@@ -850,7 +850,7 @@ namespace mongo {
string indexNamespace = entry->descriptor()->indexNamespace();
string indexName = entry->descriptor()->indexName();
- int idxNo = _details->_catalogFindIndexByName( indexName, true );
+ int idxNo = _details->_catalogFindIndexByName(_collection, indexName, true);
invariant( idxNo >= 0 );
// --------- START REAL WORK ----------
@@ -892,7 +892,7 @@ namespace mongo {
const string& indexNamespace,
int idxNo ) {
invariant( idxNo >= 0 );
- invariant( _details->_catalogFindIndexByName( indexName, true ) == idxNo );
+ invariant(_details->_catalogFindIndexByName(_collection, indexName, true) == idxNo);
// data + system.namespacesa
DurTransaction txn; // XXX
@@ -937,7 +937,7 @@ namespace mongo {
BSONObj keyPattern = spec.getObjectField("key");
IndexDescriptor desc( _collection, _getAccessMethodName(keyPattern), spec );
- int idxNo = _details->_catalogFindIndexByName( desc.indexName(), true );
+ int idxNo = _details->_catalogFindIndexByName(_collection, desc.indexName(), true);
invariant( idxNo >= 0 );
invariant( idxNo >= numIndexesReady() );
@@ -951,7 +951,8 @@ namespace mongo {
void IndexCatalog::updateTTLSetting( const IndexDescriptor* idx, long long newExpireSeconds ) {
IndexDetails* indexDetails = _getIndexDetails( idx );
- BSONElement oldExpireSecs = indexDetails->info.obj().getField("expireAfterSeconds");
+ const BSONElement oldExpireSecs =
+ _collection->docFor(indexDetails->info).getField("expireAfterSeconds");
// Important that we set the new value in-place. We are writing directly to the
// object here so must be careful not to overwrite with a longer numeric type.
@@ -1153,7 +1154,7 @@ namespace mongo {
}
IndexDetails* IndexCatalog::_getIndexDetails( const IndexDescriptor* descriptor ) const {
- int idxNo = _details->_catalogFindIndexByName( descriptor->indexName(), true );
+ int idxNo = _details->_catalogFindIndexByName(_collection, descriptor->indexName(), true);
invariant( idxNo >= 0 );
return &_details->idx( idxNo );
}
diff --git a/src/mongo/db/catalog/index_catalog_entry.cpp b/src/mongo/db/catalog/index_catalog_entry.cpp
index 8a278d1d67f..c8c55e371ef 100644
--- a/src/mongo/db/catalog/index_catalog_entry.cpp
+++ b/src/mongo/db/catalog/index_catalog_entry.cpp
@@ -148,8 +148,8 @@ namespace mongo {
}
int IndexCatalogEntry::_indexNo() const {
- int idxNo = _collection->details()->_catalogFindIndexByName( _descriptor->indexName(),
- true );
+ int idxNo = _collection->details()->_catalogFindIndexByName(
+ _collection, _descriptor->indexName(), true);
fassert( 17341, idxNo >= 0 );
return idxNo;
}
diff --git a/src/mongo/db/catalog/index_catalog_entry.h b/src/mongo/db/catalog/index_catalog_entry.h
index d3105f23bd3..19ee75ad4a6 100644
--- a/src/mongo/db/catalog/index_catalog_entry.h
+++ b/src/mongo/db/catalog/index_catalog_entry.h
@@ -144,10 +144,6 @@ namespace mongo {
// pass ownership to EntryContainer
void add( IndexCatalogEntry* entry ) { _entries.mutableVector().push_back( entry ); }
- // TODO: should the findIndexBy* methods be done here
- // and proxied in IndexCatatalog
- //IndexCatalogEntry* findIndexByName();
-
private:
OwnedPointerVector<IndexCatalogEntry> _entries;
};
diff --git a/src/mongo/db/commands/rename_collection.cpp b/src/mongo/db/commands/rename_collection.cpp
index 8c239e7e414..6a4e0bd6f89 100644
--- a/src/mongo/db/commands/rename_collection.cpp
+++ b/src/mongo/db/commands/rename_collection.cpp
@@ -234,10 +234,11 @@ namespace mongo {
// Copy over all the data from source collection to target collection.
bool insertSuccessful = true;
boost::scoped_ptr<RecordIterator> sourceIt;
+ Collection* sourceColl = NULL;
{
Client::Context srcCtx( source );
- Collection* sourceColl = srcCtx.db()->getCollection( source );
+ sourceColl = srcCtx.db()->getCollection( source );
sourceIt.reset( sourceColl->getIterator( DiskLoc(), false, CollectionScanParams::FORWARD ) );
}
@@ -246,7 +247,7 @@ namespace mongo {
BSONObj o;
{
Client::Context srcCtx( source );
- o = sourceIt->getNext().obj();
+ o = sourceColl->docFor(sourceIt->getNext());
}
// Insert and check return status of insert.
{
@@ -278,7 +279,6 @@ namespace mongo {
bool indexSuccessful = true;
{
Client::Context srcCtx( source );
- Collection* sourceColl = srcCtx.db()->getCollection( source );
IndexCatalog::IndexIterator sourceIndIt =
sourceColl->getIndexCatalog()->getIndexIterator( true );
diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp
index 39434dc84af..08ac0d9a6d1 100644
--- a/src/mongo/db/dbhelpers.cpp
+++ b/src/mongo/db/dbhelpers.cpp
@@ -79,11 +79,14 @@ namespace mongo {
/* fetch a single object from collection ns that matches query
set your db SavedContext first
*/
- bool Helpers::findOne(Collection* collection, const BSONObj &query, BSONObj& result, bool requireIndex) {
+ bool Helpers::findOne(Collection* collection,
+ const BSONObj &query,
+ BSONObj& result,
+ bool requireIndex) {
DiskLoc loc = findOne( collection, query, requireIndex );
if ( loc.isNull() )
return false;
- result = loc.obj();
+ result = collection->docFor(loc);
return true;
}
diff --git a/src/mongo/db/dbhelpers.h b/src/mongo/db/dbhelpers.h
index 86a40682ced..8f5a188ac86 100644
--- a/src/mongo/db/dbhelpers.h
+++ b/src/mongo/db/dbhelpers.h
@@ -77,10 +77,12 @@ namespace mongo {
@return true if object found
*/
- static bool findOne(Collection* collection, const BSONObj &query,
- BSONObj& result, bool requireIndex = false);
- static DiskLoc findOne(Collection* collection, const BSONObj &query,
- bool requireIndex);
+ static bool findOne(Collection* collection,
+ const BSONObj &query,
+ BSONObj& result,
+ bool requireIndex = false);
+
+ static DiskLoc findOne(Collection* collection, const BSONObj &query, bool requireIndex);
/**
* have to be locked already
diff --git a/src/mongo/db/diskloc.h b/src/mongo/db/diskloc.h
index e4807103009..6924be86a69 100644
--- a/src/mongo/db/diskloc.h
+++ b/src/mongo/db/diskloc.h
@@ -57,7 +57,6 @@ namespace mongo {
int _a; // this will be volume, file #, etc. but is a logical value could be anything depending on storage engine
int ofs;
- Record* rec() const; // TODO(ERH): remove
public:
enum SentinelValues {
@@ -155,13 +154,6 @@ namespace mongo {
size_t operator()( DiskLoc loc ) const;
};
- /* Get the "thing" associated with this disk location.
- it is assumed the object is what you say it is -- you must assure that
- (think of this as an unchecked type cast)
- Note: set your Context first so that the database to which the diskloc applies is known.
- */
- BSONObj obj() const; // TODO(ERH): remove
-
/// members for Sorter
struct SorterDeserializeSettings {}; // unused
void serializeForSorter(BufBuilder& buf) const { buf.appendStruct(*this); }
diff --git a/src/mongo/db/storage/record.cpp b/src/mongo/db/storage/record.cpp
index 23bf3ebb28c..e3fe67f25a9 100644
--- a/src/mongo/db/storage/record.cpp
+++ b/src/mongo/db/storage/record.cpp
@@ -524,16 +524,6 @@ namespace mongo {
return this;
}
- Record* DiskLoc::rec() const {
- // XXX-ERH
- verify(a() != -1);
- return cc().getContext()->db()->getExtentManager().recordForV1( *this );
- }
-
- BSONObj DiskLoc::obj() const {
- return BSONObj( rec()->accessed()->data() );
- }
-
void Record::_accessing() const {
if ( likelyInPhysicalMemory() )
return;
diff --git a/src/mongo/db/structure/catalog/namespace_details.cpp b/src/mongo/db/structure/catalog/namespace_details.cpp
index 66a27cb593a..33a812a3bda 100644
--- a/src/mongo/db/structure/catalog/namespace_details.cpp
+++ b/src/mongo/db/structure/catalog/namespace_details.cpp
@@ -466,11 +466,13 @@ namespace mongo {
}
}
- int NamespaceDetails::_catalogFindIndexByName(const StringData& name,
+ int NamespaceDetails::_catalogFindIndexByName(const Collection* coll,
+ const StringData& name,
bool includeBackgroundInProgress) const {
IndexIterator i = ii(includeBackgroundInProgress);
while( i.more() ) {
- if ( name == i.next().info.obj().getStringField("name") )
+ const BSONObj obj = coll->docFor(i.next().info);
+ if ( name == obj.getStringField("name") )
return i.pos()-1;
}
return -1;
diff --git a/src/mongo/db/structure/catalog/namespace_details.h b/src/mongo/db/structure/catalog/namespace_details.h
index e7579b6e5f5..5697075c727 100644
--- a/src/mongo/db/structure/catalog/namespace_details.h
+++ b/src/mongo/db/structure/catalog/namespace_details.h
@@ -37,9 +37,6 @@
namespace mongo {
class Collection;
- class Database;
- class IndexCatalog;
- class IndexCatalogEntry;
/* deleted lists -- linked lists of deleted records -- are placed in 'buckets' of various sizes
so you can look for a deleterecord about the right size.
@@ -334,16 +331,21 @@ namespace mongo {
*/
static int quantizePowerOf2AllocationSpace(int allocSize);
- public:
NamespaceDetails *writingWithoutExtra() {
return ( NamespaceDetails* ) getDur().writingPtr( this, sizeof( NamespaceDetails ) );
}
/** Make all linked Extra objects writeable as well */
NamespaceDetails *writingWithExtra();
- // @return offset in indexes[]
- int _catalogFindIndexByName( const StringData& name,
- bool includeBackgroundInProgress = false) const;
+ /**
+ * Returns the offset of the specified index name within the array of indexes. Must be
+ * passed-in the owning collection to resolve the index record entries to objects.
+ *
+ * @return > 0 if index name was found, -1 otherwise.
+ */
+ int _catalogFindIndexByName(const Collection* coll,
+ const StringData& name,
+ bool includeBackgroundInProgress) const;
private:
diff --git a/src/mongo/dbtests/dbhelper_tests.cpp b/src/mongo/dbtests/dbhelper_tests.cpp
index 1424ce3c861..8ee890939fb 100644
--- a/src/mongo/dbtests/dbhelper_tests.cpp
+++ b/src/mongo/dbtests/dbhelper_tests.cpp
@@ -26,9 +26,10 @@
* then also delete it in the license file.
*/
+#include "mongo/client/dbclientcursor.h"
+#include "mongo/db/catalog/collection.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/dbtests/dbtests.h"
-#include "mongo/client/dbclientcursor.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -126,7 +127,7 @@ namespace mongo {
{
// search _id range (0, 10)
Lock::DBRead lk( ns );
- Client::Context ctx( ns );
+
KeyRange range( ns,
BSON( "_id" << 0 ),
BSON( "_id" << numDocsInserted ),
@@ -143,9 +144,13 @@ namespace mongo {
ASSERT_NOT_EQUALS( estSizeBytes, 0 );
ASSERT_LESS_THAN( estSizeBytes, maxSizeBytes );
+ Database* db = dbHolder().get(nsToDatabase(range.ns), storageGlobalParams.dbpath);
+ const Collection* collection = db->getCollection(ns);
+
// Make sure all the disklocs actually correspond to the right info
- for ( set<DiskLoc>::iterator it = locs.begin(); it != locs.end(); ++it ) {
- ASSERT_EQUALS( it->obj()["tag"].OID(), tag );
+ for ( set<DiskLoc>::const_iterator it = locs.begin(); it != locs.end(); ++it ) {
+ const BSONObj obj = collection->docFor(*it);
+ ASSERT_EQUALS(obj["tag"].OID(), tag);
}
}
}
diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp
index 84131927ba6..81f51a107fc 100644
--- a/src/mongo/dbtests/indexupdatetests.cpp
+++ b/src/mongo/dbtests/indexupdatetests.cpp
@@ -497,24 +497,24 @@ namespace IndexUpdateTests {
IndexCatalog::IndexBuildBlock* b = halfAddIndex("b");
IndexCatalog::IndexBuildBlock* c = halfAddIndex("c");
IndexCatalog::IndexBuildBlock* d = halfAddIndex("d");
- int offset = nsd->findIndexByName( "b_1", true );
+ int offset = nsd->_catalogFindIndexByName( "b_1", true );
ASSERT_EQUALS(2, offset);
delete b;
- ASSERT_EQUALS(2, nsd->findIndexByName( "c_1", true ) );
- ASSERT_EQUALS(3, nsd->findIndexByName( "d_1", true ) );
+ ASSERT_EQUALS(2, nsd->_catalogFindIndexByName( "c_1", true ) );
+ ASSERT_EQUALS(3, nsd->_catalogFindIndexByName( "d_1", true ) );
- offset = nsd->findIndexByName( "d_1", true );
+ offset = nsd->_catalogFindIndexByName( "d_1", true );
delete d;
- ASSERT_EQUALS(2, nsd->findIndexByName( "c_1", true ) );
- ASSERT( nsd->findIndexByName( "d_1", true ) < 0 );
+ ASSERT_EQUALS(2, nsd->_catalogFindIndexByName( "c_1", true ) );
+ ASSERT( nsd->_catalogFindIndexByName( "d_1", true ) < 0 );
- offset = nsd->findIndexByName( "a_1", true );
+ offset = nsd->_catalogFindIndexByName( "a_1", true );
delete a;
- ASSERT_EQUALS(1, nsd->findIndexByName( "c_1", true ));
+ ASSERT_EQUALS(1, nsd->_catalogFindIndexByName( "c_1", true ));
delete c;
}
diff --git a/src/mongo/dbtests/query_stage_and.cpp b/src/mongo/dbtests/query_stage_and.cpp
index 8f59112c0a8..4570dbec80c 100644
--- a/src/mongo/dbtests/query_stage_and.cpp
+++ b/src/mongo/dbtests/query_stage_and.cpp
@@ -178,9 +178,9 @@ namespace QueryStageAnd {
getLocs(&data, coll);
size_t memUsageBefore = ah->getMemUsage();
for (set<DiskLoc>::const_iterator it = data.begin(); it != data.end(); ++it) {
- if (it->obj()["foo"].numberInt() == 15) {
+ if (coll->docFor(*it)["foo"].numberInt() == 15) {
ah->invalidate(*it, INVALIDATION_DELETION);
- remove(it->obj());
+ remove(coll->docFor(*it));
break;
}
}
@@ -280,7 +280,7 @@ namespace QueryStageAnd {
size_t memUsageBefore = ah->getMemUsage();
for (set<DiskLoc>::const_iterator it = data.begin(); it != data.end(); ++it) {
- if (0 == deletedObj.woCompare(it->obj())) {
+ if (0 == deletedObj.woCompare(coll->docFor(*it))) {
ah->invalidate(*it, INVALIDATION_DELETION);
break;
}
@@ -302,7 +302,7 @@ namespace QueryStageAnd {
PlanStage::StageState status = ah->work(&id);
if (PlanStage::ADVANCED != status) { continue; }
WorkingSetMember* wsm = ws.get(id);
- ASSERT_NOT_EQUALS(0, deletedObj.woCompare(wsm->loc.obj()));
+ ASSERT_NOT_EQUALS(0, deletedObj.woCompare(coll->docFor(wsm->loc)));
++count;
}
@@ -798,7 +798,7 @@ namespace QueryStageAnd {
// and make sure it shows up in the flagged results.
ah->prepareToYield();
ah->invalidate(*data.begin(), INVALIDATION_DELETION);
- remove(data.begin()->obj());
+ remove(coll->docFor(*data.begin()));
ah->recoverFromYield();
// Make sure the nuked obj is actually in the flagged data.
@@ -837,7 +837,7 @@ namespace QueryStageAnd {
// not flagged.
ah->prepareToYield();
ah->invalidate(*it, INVALIDATION_DELETION);
- remove(it->obj());
+ remove(coll->docFor(*it));
ah->recoverFromYield();
// Get all results aside from the two we killed.
@@ -1098,11 +1098,11 @@ namespace QueryStageAnd {
WorkingSetID id = WorkingSet::INVALID_ID;
PlanStage::StageState status = ah->work(&id);
if (PlanStage::ADVANCED != status) { continue; }
- BSONObj thisObj = ws.get(id)->loc.obj();
+ BSONObj thisObj = coll->docFor(ws.get(id)->loc);
ASSERT_EQUALS(7 + count, thisObj["bar"].numberInt());
++count;
if (WorkingSet::INVALID_ID != lastId) {
- BSONObj lastObj = ws.get(lastId)->loc.obj();
+ BSONObj lastObj = coll->docFor(ws.get(lastId)->loc);
ASSERT_LESS_THAN(lastObj["bar"].woCompare(thisObj["bar"]), 0);
}
lastId = id;
diff --git a/src/mongo/dbtests/query_stage_collscan.cpp b/src/mongo/dbtests/query_stage_collscan.cpp
index 7bdfca3ba3f..e82513a79b2 100644
--- a/src/mongo/dbtests/query_stage_collscan.cpp
+++ b/src/mongo/dbtests/query_stage_collscan.cpp
@@ -523,7 +523,7 @@ namespace QueryStageCollectionScan {
PlanStage::StageState state = scan->work(&id);
if (PlanStage::ADVANCED == state) {
WorkingSetMember* member = ws.get(id);
- ASSERT_EQUALS(locs[count].obj()["foo"].numberInt(),
+ ASSERT_EQUALS(coll->docFor(locs[count])["foo"].numberInt(),
member->obj["foo"].numberInt());
++count;
}
@@ -532,7 +532,7 @@ namespace QueryStageCollectionScan {
// Remove locs[count].
scan->prepareToYield();
scan->invalidate(locs[count], INVALIDATION_DELETION);
- remove(locs[count].obj());
+ remove(coll->docFor(locs[count]));
scan->recoverFromYield();
// Skip over locs[count].
@@ -544,7 +544,7 @@ namespace QueryStageCollectionScan {
PlanStage::StageState state = scan->work(&id);
if (PlanStage::ADVANCED == state) {
WorkingSetMember* member = ws.get(id);
- ASSERT_EQUALS(locs[count].obj()["foo"].numberInt(),
+ ASSERT_EQUALS(coll->docFor(locs[count])["foo"].numberInt(),
member->obj["foo"].numberInt());
++count;
}
@@ -584,7 +584,7 @@ namespace QueryStageCollectionScan {
PlanStage::StageState state = scan->work(&id);
if (PlanStage::ADVANCED == state) {
WorkingSetMember* member = ws.get(id);
- ASSERT_EQUALS(locs[count].obj()["foo"].numberInt(),
+ ASSERT_EQUALS(coll->docFor(locs[count])["foo"].numberInt(),
member->obj["foo"].numberInt());
++count;
}
@@ -593,7 +593,7 @@ namespace QueryStageCollectionScan {
// Remove locs[count].
scan->prepareToYield();
scan->invalidate(locs[count], INVALIDATION_DELETION);
- remove(locs[count].obj());
+ remove(coll->docFor(locs[count]));
scan->recoverFromYield();
// Skip over locs[count].
@@ -605,7 +605,7 @@ namespace QueryStageCollectionScan {
PlanStage::StageState state = scan->work(&id);
if (PlanStage::ADVANCED == state) {
WorkingSetMember* member = ws.get(id);
- ASSERT_EQUALS(locs[count].obj()["foo"].numberInt(),
+ ASSERT_EQUALS(coll->docFor(locs[count])["foo"].numberInt(),
member->obj["foo"].numberInt());
++count;
}
@@ -657,7 +657,7 @@ namespace QueryStageCollectionScan {
// Delete the thing we're fetching.
scan->prepareToYield();
scan->invalidate(locs[0], INVALIDATION_DELETION);
- remove(locs[0].obj());
+ remove(coll->docFor(locs[0]));
scan->recoverFromYield();
// Turn fetches off.
@@ -671,7 +671,7 @@ namespace QueryStageCollectionScan {
PlanStage::StageState state = scan->work(&id);
if (PlanStage::ADVANCED == state) {
WorkingSetMember* member = ws.get(id);
- ASSERT_EQUALS(locs[count].obj()["foo"].numberInt(),
+ ASSERT_EQUALS(coll->docFor(locs[count])["foo"].numberInt(),
member->obj["foo"].numberInt());
++count;
}
diff --git a/src/mongo/dbtests/query_stage_fetch.cpp b/src/mongo/dbtests/query_stage_fetch.cpp
index 4eea0e115ad..8abbab2f1db 100644
--- a/src/mongo/dbtests/query_stage_fetch.cpp
+++ b/src/mongo/dbtests/query_stage_fetch.cpp
@@ -324,7 +324,7 @@ namespace QueryStageFetch {
WorkingSetMember mockMember;
mockMember.state = WorkingSetMember::LOC_AND_UNOWNED_OBJ;
mockMember.loc = *locs.begin();
- mockMember.obj = mockMember.loc.obj();
+ mockMember.obj = coll->docFor(mockMember.loc);
// Points into our DB.
ASSERT_FALSE(mockMember.obj.isOwned());
mockStage->pushBack(mockMember);
diff --git a/src/mongo/dbtests/query_stage_sort.cpp b/src/mongo/dbtests/query_stage_sort.cpp
index c8499a28976..71685c7d21a 100644
--- a/src/mongo/dbtests/query_stage_sort.cpp
+++ b/src/mongo/dbtests/query_stage_sort.cpp
@@ -89,7 +89,7 @@ namespace QueryStageSortTests {
WorkingSetMember member;
member.loc = *it;
member.state = WorkingSetMember::LOC_AND_UNOWNED_OBJ;
- member.obj = it->obj();
+ member.obj = coll->docFor(*it);
ASSERT_FALSE(member.obj.isOwned());
ms->pushBack(member);
}
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp
index 96f83c61913..0fe9362e542 100644
--- a/src/mongo/dbtests/querytests.cpp
+++ b/src/mongo/dbtests/querytests.cpp
@@ -120,7 +120,7 @@ namespace QueryTests {
ASSERT( Helpers::findOne( _collection, query, ret, true ) );
ASSERT_EQUALS( string( "b" ), ret.firstElement().fieldName() );
// Cross check with findOne() returning location.
- ASSERT_EQUALS( ret, Helpers::findOne( _collection, query, true ).obj() );
+ ASSERT_EQUALS(ret, _collection->docFor(Helpers::findOne(_collection, query, true)));
}
};
@@ -134,7 +134,7 @@ namespace QueryTests {
// Check findOne() returning object, allowing unindexed scan.
ASSERT( Helpers::findOne( _collection, query, ret, false ) );
// Check findOne() returning location, allowing unindexed scan.
- ASSERT_EQUALS( ret, Helpers::findOne( _collection, query, false ).obj() );
+ ASSERT_EQUALS(ret, _collection->docFor(Helpers::findOne(_collection, query, false)));
// Check findOne() returning object, requiring indexed scan without index.
ASSERT_THROWS( Helpers::findOne( _collection, query, ret, true ), MsgAssertionException );
@@ -145,7 +145,7 @@ namespace QueryTests {
// Check findOne() returning object, requiring indexed scan with index.
ASSERT( Helpers::findOne( _collection, query, ret, true ) );
// Check findOne() returning location, requiring indexed scan with index.
- ASSERT_EQUALS( ret, Helpers::findOne( _collection, query, true ).obj() );
+ ASSERT_EQUALS(ret, _collection->docFor(Helpers::findOne(_collection, query, true)));
}
};
@@ -176,7 +176,7 @@ namespace QueryTests {
BSONObj ret;
ASSERT( Helpers::findOne( _collection, query, ret, false ) );
ASSERT( ret.isEmpty() );
- ASSERT_EQUALS( ret, Helpers::findOne( _collection, query, false ).obj() );
+ ASSERT_EQUALS(ret, _collection->docFor(Helpers::findOne(_collection, query, false)));
}
};
diff --git a/src/mongo/dbtests/queryutiltests.cpp b/src/mongo/dbtests/queryutiltests.cpp
index 95818b0c383..ab2184b8cd7 100644
--- a/src/mongo/dbtests/queryutiltests.cpp
+++ b/src/mongo/dbtests/queryutiltests.cpp
@@ -1614,7 +1614,7 @@ namespace QueryUtilTests {
IndexDescriptor* desc = catalog->findIndexByKeyPattern( key );
invariant( desc );
- int x = nsd()->_catalogFindIndexByName( desc->indexName() );
+ int x = nsd()->_catalogFindIndexByName(collection(), desc->indexName(), false);
invariant( x >= 0 );
return x;
diff --git a/src/mongo/dbtests/repltests.cpp b/src/mongo/dbtests/repltests.cpp
index c7a51d65238..46152ad3555 100644
--- a/src/mongo/dbtests/repltests.cpp
+++ b/src/mongo/dbtests/repltests.cpp
@@ -162,7 +162,7 @@ namespace ReplTests {
CollectionScanParams::FORWARD );
while ( !it->isEOF() ) {
DiskLoc currLoc = it->getNext();
- ops.push_back( currLoc.obj() );
+ ops.push_back(coll->docFor(currLoc));
}
delete it;
}
@@ -195,7 +195,7 @@ namespace ReplTests {
out() << "all for " << ns << endl;
while ( !it->isEOF() ) {
DiskLoc currLoc = it->getNext();
- out() << currLoc.obj().toString() << endl;
+ out() << coll->docFor(currLoc).toString() << endl;
}
delete it;
}
diff --git a/src/mongo/s/d_split.cpp b/src/mongo/s/d_split.cpp
index 2261158b367..26b6f2a8bb3 100644
--- a/src/mongo/s/d_split.cpp
+++ b/src/mongo/s/d_split.cpp
@@ -179,7 +179,7 @@ namespace mongo {
// This is a fetch, but it's OK. The underlying code won't throw a page fault
// exception.
- BSONObj obj = loc.obj();
+ BSONObj obj = collection->docFor(loc);
BSONObjIterator j( keyPattern );
BSONElement real;
for ( int x=0; x <= k; x++ )