summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2015-04-10 20:45:50 -0400
committerBenety Goh <benety@mongodb.com>2015-04-14 08:29:17 -0400
commitd8413d075b199afd2623791b8656133ca8681513 (patch)
tree50fdffb1a20f0ec980d63cc69fafb992a72461bb /src/mongo/db
parent81a1f70b87b3f3754931829b11faa0a53df64527 (diff)
downloadmongo-d8413d075b199afd2623791b8656133ca8681513.tar.gz
SERVER-17894 de-inlined InternalPlanner
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/commands/dbhash.cpp1
-rw-r--r--src/mongo/db/commands/test_commands.cpp1
-rw-r--r--src/mongo/db/dbcommands.cpp4
-rw-r--r--src/mongo/db/exec/text.cpp1
-rw-r--r--src/mongo/db/query/SConscript10
-rw-r--r--src/mongo/db/query/get_executor.cpp2
-rw-r--r--src/mongo/db/query/internal_plans.cpp130
-rw-r--r--src/mongo/db/query/internal_plans.h88
8 files changed, 156 insertions, 81 deletions
diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp
index 2d531a5a4c2..9f12c82d699 100644
--- a/src/mongo/db/commands/dbhash.cpp
+++ b/src/mongo/db/commands/dbhash.cpp
@@ -34,6 +34,7 @@
#include <boost/scoped_ptr.hpp>
+#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_catalog_entry.h"
#include "mongo/db/client.h"
diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp
index 14a636e4b5a..6ab83549325 100644
--- a/src/mongo/db/commands/test_commands.cpp
+++ b/src/mongo/db/commands/test_commands.cpp
@@ -35,6 +35,7 @@
#include "mongo/base/init.h"
#include "mongo/base/initializer_context.h"
#include "mongo/db/catalog/capped_utils.h"
+#include "mongo/db/catalog/collection.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/db_raii.h"
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index 5b3cf3d46b9..7857b22e502 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -36,7 +36,6 @@
#include <time.h>
#include "mongo/base/disallow_copying.h"
-#include "mongo/base/init.h"
#include "mongo/base/status.h"
#include "mongo/bson/util/builder.h"
#include "mongo/db/audit.h"
@@ -50,6 +49,7 @@
#include "mongo/db/background.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/catalog/coll_mod.h"
+#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/drop_collection.h"
#include "mongo/db/catalog/drop_database.h"
@@ -66,6 +66,8 @@
#include "mongo/db/service_context_d.h"
#include "mongo/db/service_context.h"
#include "mongo/db/index_builder.h"
+#include "mongo/db/index/index_access_method.h"
+#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/instance.h"
#include "mongo/db/introspect.h"
#include "mongo/db/jsobj.h"
diff --git a/src/mongo/db/exec/text.cpp b/src/mongo/db/exec/text.cpp
index 48be5d2e213..67596b62157 100644
--- a/src/mongo/db/exec/text.cpp
+++ b/src/mongo/db/exec/text.cpp
@@ -31,6 +31,7 @@
#include "mongo/base/owned_pointer_vector.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/exec/filter.h"
+#include "mongo/db/exec/index_scan.h"
#include "mongo/db/exec/scoped_timer.h"
#include "mongo/db/exec/working_set.h"
#include "mongo/db/exec/working_set_common.h"
diff --git a/src/mongo/db/query/SConscript b/src/mongo/db/query/SConscript
index 856e00f3007..786de245ca9 100644
--- a/src/mongo/db/query/SConscript
+++ b/src/mongo/db/query/SConscript
@@ -45,6 +45,7 @@ env.Library(
"stage_builder.cpp",
],
LIBDEPS=[
+ "internal_plans",
"query_planner",
"query_planner_test_lib",
"$BUILD_DIR/mongo/expression_algo",
@@ -117,6 +118,15 @@ env.CppUnitTest(
)
env.Library(
+ target="internal_plans",
+ source=[
+ "internal_plans.cpp"
+ ],
+ LIBDEPS=[
+ ],
+)
+
+env.Library(
target="lite_parsed_query",
source=[
"lite_parsed_query.cpp"
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index 495b0b0f395..d07b4eaf820 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -51,6 +51,7 @@
#include "mongo/db/exec/subplan.h"
#include "mongo/db/exec/update.h"
#include "mongo/db/index_names.h"
+#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/matcher/expression_algo.h"
#include "mongo/db/ops/update_lifecycle.h"
#include "mongo/db/query/canonical_query.h"
@@ -70,6 +71,7 @@
#include "mongo/db/server_options.h"
#include "mongo/db/server_parameters.h"
#include "mongo/db/service_context.h"
+#include "mongo/db/storage_options.h"
#include "mongo/db/storage/oplog_hack.h"
#include "mongo/s/d_state.h"
#include "mongo/scripting/engine.h"
diff --git a/src/mongo/db/query/internal_plans.cpp b/src/mongo/db/query/internal_plans.cpp
new file mode 100644
index 00000000000..9a38020d00a
--- /dev/null
+++ b/src/mongo/db/query/internal_plans.cpp
@@ -0,0 +1,130 @@
+/**
+ * Copyright (C) 2015 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/platform/basic.h"
+
+#include "mongo/db/query/internal_plans.h"
+
+#include "mongo/db/catalog/database.h"
+#include "mongo/db/client.h"
+#include "mongo/db/exec/collection_scan.h"
+#include "mongo/db/exec/eof.h"
+#include "mongo/db/exec/fetch.h"
+#include "mongo/db/exec/index_scan.h"
+#include "mongo/db/query/plan_executor.h"
+
+namespace mongo {
+
+ // static
+ PlanExecutor* InternalPlanner::collectionScan(OperationContext* txn,
+ StringData ns,
+ Collection* collection,
+ const Direction direction,
+ const RecordId startLoc) {
+ WorkingSet* ws = new WorkingSet();
+
+ if (NULL == collection) {
+ EOFStage* eof = new EOFStage();
+ PlanExecutor* exec;
+ // Takes ownership of 'ws' and 'eof'.
+ Status execStatus = PlanExecutor::make(txn,
+ ws,
+ eof,
+ ns.toString(),
+ PlanExecutor::YIELD_MANUAL,
+ &exec);
+ invariant(execStatus.isOK());
+ return exec;
+ }
+
+ invariant( ns == collection->ns().ns() );
+
+ CollectionScanParams params;
+ params.collection = collection;
+ params.start = startLoc;
+
+ if (FORWARD == direction) {
+ params.direction = CollectionScanParams::FORWARD;
+ }
+ else {
+ params.direction = CollectionScanParams::BACKWARD;
+ }
+
+ CollectionScan* cs = new CollectionScan(txn, params, ws, NULL);
+ PlanExecutor* exec;
+ // Takes ownership of 'ws' and 'cs'.
+ Status execStatus = PlanExecutor::make(txn,
+ ws,
+ cs,
+ collection,
+ PlanExecutor::YIELD_MANUAL,
+ &exec);
+ invariant(execStatus.isOK());
+ return exec;
+ }
+
+ // static
+ PlanExecutor* InternalPlanner::indexScan(OperationContext* txn,
+ const Collection* collection,
+ const IndexDescriptor* descriptor,
+ const BSONObj& startKey, const BSONObj& endKey,
+ bool endKeyInclusive, Direction direction,
+ int options) {
+ invariant(collection);
+ invariant(descriptor);
+
+ IndexScanParams params;
+ params.descriptor = descriptor;
+ params.direction = direction;
+ params.bounds.isSimpleRange = true;
+ params.bounds.startKey = startKey;
+ params.bounds.endKey = endKey;
+ params.bounds.endKeyInclusive = endKeyInclusive;
+
+ WorkingSet* ws = new WorkingSet();
+ IndexScan* ix = new IndexScan(txn, params, ws, NULL);
+
+ PlanStage* root = ix;
+
+ if (IXSCAN_FETCH & options) {
+ root = new FetchStage(txn, ws, root, NULL, collection);
+ }
+
+ PlanExecutor* exec;
+ // Takes ownership of 'ws' and 'root'.
+ Status execStatus = PlanExecutor::make(txn,
+ ws,
+ root,
+ collection,
+ PlanExecutor::YIELD_MANUAL,
+ &exec);
+ invariant(execStatus.isOK());
+ return exec;
+ }
+
+} // namespace mongo
diff --git a/src/mongo/db/query/internal_plans.h b/src/mongo/db/query/internal_plans.h
index be2d6089f4e..d9e763828ca 100644
--- a/src/mongo/db/query/internal_plans.h
+++ b/src/mongo/db/query/internal_plans.h
@@ -28,17 +28,16 @@
#pragma once
-#include "mongo/db/catalog/database.h"
-#include "mongo/db/client.h"
-#include "mongo/db/exec/collection_scan.h"
-#include "mongo/db/exec/eof.h"
-#include "mongo/db/exec/fetch.h"
-#include "mongo/db/exec/index_scan.h"
-#include "mongo/db/query/plan_executor.h"
+#include "mongo/base/string_data.h"
+#include "mongo/db/record_id.h"
namespace mongo {
+ class BSONObj;
+ class Collection;
+ class IndexDescriptor;
class OperationContext;
+ class PlanExecutor;
/**
* The internal planner is a one-stop shop for "off-the-shelf" plans. Most internal procedures
@@ -68,48 +67,7 @@ namespace mongo {
StringData ns,
Collection* collection,
const Direction direction = FORWARD,
- const RecordId startLoc = RecordId()) {
- WorkingSet* ws = new WorkingSet();
-
- if (NULL == collection) {
- EOFStage* eof = new EOFStage();
- PlanExecutor* exec;
- // Takes ownership of 'ws' and 'eof'.
- Status execStatus = PlanExecutor::make(txn,
- ws,
- eof,
- ns.toString(),
- PlanExecutor::YIELD_MANUAL,
- &exec);
- invariant(execStatus.isOK());
- return exec;
- }
-
- invariant( ns == collection->ns().ns() );
-
- CollectionScanParams params;
- params.collection = collection;
- params.start = startLoc;
-
- if (FORWARD == direction) {
- params.direction = CollectionScanParams::FORWARD;
- }
- else {
- params.direction = CollectionScanParams::BACKWARD;
- }
-
- CollectionScan* cs = new CollectionScan(txn, params, ws, NULL);
- PlanExecutor* exec;
- // Takes ownership of 'ws' and 'cs'.
- Status execStatus = PlanExecutor::make(txn,
- ws,
- cs,
- collection,
- PlanExecutor::YIELD_MANUAL,
- &exec);
- invariant(execStatus.isOK());
- return exec;
- }
+ const RecordId startLoc = RecordId());
/**
* Return an index scan. Caller owns returned pointer.
@@ -119,38 +77,8 @@ namespace mongo {
const IndexDescriptor* descriptor,
const BSONObj& startKey, const BSONObj& endKey,
bool endKeyInclusive, Direction direction = FORWARD,
- int options = 0) {
- invariant(collection);
- invariant(descriptor);
-
- IndexScanParams params;
- params.descriptor = descriptor;
- params.direction = direction;
- params.bounds.isSimpleRange = true;
- params.bounds.startKey = startKey;
- params.bounds.endKey = endKey;
- params.bounds.endKeyInclusive = endKeyInclusive;
-
- WorkingSet* ws = new WorkingSet();
- IndexScan* ix = new IndexScan(txn, params, ws, NULL);
-
- PlanStage* root = ix;
-
- if (IXSCAN_FETCH & options) {
- root = new FetchStage(txn, ws, root, NULL, collection);
- }
+ int options = 0);
- PlanExecutor* exec;
- // Takes ownership of 'ws' and 'root'.
- Status execStatus = PlanExecutor::make(txn,
- ws,
- root,
- collection,
- PlanExecutor::YIELD_MANUAL,
- &exec);
- invariant(execStatus.isOK());
- return exec;
- }
};
} // namespace mongo