diff --git a/jstests/aggregation/disabled/testexplain.js b/jstests/aggregation/testexplain.js similarity index 99% rename from jstests/aggregation/disabled/testexplain.js rename to jstests/aggregation/testexplain.js index 0b3e1a807687d..6172df350e816 100644 --- a/jstests/aggregation/disabled/testexplain.js +++ b/jstests/aggregation/testexplain.js @@ -1,4 +1,4 @@ -//if ( 0 ) { +if ( 0 ) { /* load the test documents */ load('jstests/aggregation/data/articles.js'); @@ -557,4 +557,4 @@ var edi3result = { assert(documentEq(edi3, edi3result), 'edi3 failed'); -//} +} diff --git a/src/mongo/db/commands/pipeline.h b/src/mongo/db/commands/pipeline.h index 212951c000945..8c3ad2f810457 100755 --- a/src/mongo/db/commands/pipeline.h +++ b/src/mongo/db/commands/pipeline.h @@ -122,7 +122,7 @@ namespace mongo { @returns true if this is an explain */ - bool getExplain() const; + bool isExplain() const; /** The aggregation command name. @@ -217,7 +217,7 @@ namespace mongo { return splitMongodPipeline; } - inline bool Pipeline::getExplain() const { + inline bool Pipeline::isExplain() const { return explain; } diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp index 54c9ac6d45a43..71449ea53c3ce 100755 --- a/src/mongo/db/commands/pipeline_command.cpp +++ b/src/mongo/db/commands/pipeline_command.cpp @@ -160,7 +160,7 @@ namespace mongo { lk.reset(new Lock::GlobalRead()); Client::ReadContext ctx(ns, dbpath, requiresAuth()); // read lock - PipelineD::prepareCursorSource(&pSource, pPipeline, db, pCtx); + pSource = PipelineD::prepareCursorSource(pPipeline, db, pCtx); /* release the Cursor before the lock gets released */ pSource->releaseCursor(); @@ -182,14 +182,13 @@ namespace mongo { intrusive_ptr &pPipeline, intrusive_ptr &pCtx) { - intrusive_ptr pSource; - scoped_ptr lk; if(lockGlobally()) lk.reset(new Lock::GlobalRead()); Client::ReadContext ctx(ns, dbpath, requiresAuth()); // read lock - PipelineD::prepareCursorSource(&pSource, pPipeline, db, pCtx); + intrusive_ptr pSource( + PipelineD::prepareCursorSource(pPipeline, db, pCtx)); return executePipeline(result, errmsg, ns, pPipeline, pSource, pCtx); } @@ -293,18 +292,10 @@ namespace mongo { string ns(parseNs(db, cmdObj)); - if (pPipeline->getExplain()) + if (pPipeline->isExplain()) return runExplain(result, errmsg, ns, db, pPipeline, pCtx); else return runExecute(result, errmsg, ns, db, pPipeline, pCtx); - -#ifdef NEVER - intrusive_ptr pSource; - PipelineD::prepareCursorSource( - &pSource, pPipeline, db, pCtx); - - return executePipeline(result, errmsg, ns, pPipeline, pSource, pCtx); -#endif } } // namespace mongo diff --git a/src/mongo/db/commands/pipeline_d.cpp b/src/mongo/db/commands/pipeline_d.cpp index 8054261c25781..b46b06259e044 100755 --- a/src/mongo/db/commands/pipeline_d.cpp +++ b/src/mongo/db/commands/pipeline_d.cpp @@ -24,8 +24,7 @@ namespace mongo { - void PipelineD::prepareCursorSource( - intrusive_ptr *ppSource, + intrusive_ptr PipelineD::prepareCursorSource( const intrusive_ptr &pPipeline, const string &dbName, const intrusive_ptr &pExpCtx) { @@ -134,9 +133,10 @@ namespace mongo { } /* wrap the cursor with a DocumentSource and return that */ - *ppSource = DocumentSourceCursor::create(pCursor, dbName, pExpCtx); + intrusive_ptr pSource( + DocumentSourceCursor::create(pCursor, dbName, pExpCtx)); - (*ppSource)->setNamespace(fullName); + pSource->setNamespace(fullName); /* Note the query and sort @@ -145,9 +145,11 @@ namespace mongo { referenced (by reference) by the cursor, which doesn't make its own copies of them. */ - (*ppSource)->setQuery(pQueryObj); + pSource->setQuery(pQueryObj); if (initSort) - (*ppSource)->setSort(pSortObj); + pSource->setSort(pSortObj); + + return pSource; } } // namespace mongo diff --git a/src/mongo/db/commands/pipeline_d.h b/src/mongo/db/commands/pipeline_d.h index 4acf4a0597cf6..a514fe22fbcde 100755 --- a/src/mongo/db/commands/pipeline_d.h +++ b/src/mongo/db/commands/pipeline_d.h @@ -45,13 +45,12 @@ namespace mongo { early match can be removed and replaced with a Cursor that will do an index scan. - @param ppSource where to put the wrapped Cursor @param pPipeline the logical "this" for this operation @param dbName the name of the database @param pExpCtx the expression context for this pipeline + @returns the cursor that was created */ - static void prepareCursorSource( - intrusive_ptr *ppSource, + static intrusive_ptr prepareCursorSource( const intrusive_ptr &pPipeline, const string &dbName, const intrusive_ptr &pExpCtx);