summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_solution.h
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2013-08-01 11:01:23 -0400
committerHari Khalsa <hkhalsa@10gen.com>2013-08-05 10:46:23 -0400
commitbd0cdbf21d2e91a4b63db6d092378a86f058c73d (patch)
tree0c4797e8dffcbb1aa3db47b52e995b0f21a58ebc /src/mongo/db/query/query_solution.h
parent00eeec1ab83c8f4921d1bc1352221168a3a01900 (diff)
downloadmongo-bd0cdbf21d2e91a4b63db6d092378a86f058c73d.tar.gz
SERVER-10376 SERVER-10026 end-to-end part 1: run non-indexed queries
Diffstat (limited to 'src/mongo/db/query/query_solution.h')
-rw-r--r--src/mongo/db/query/query_solution.h59
1 files changed, 46 insertions, 13 deletions
diff --git a/src/mongo/db/query/query_solution.h b/src/mongo/db/query/query_solution.h
index bd89e8f1c48..bc57a3c969f 100644
--- a/src/mongo/db/query/query_solution.h
+++ b/src/mongo/db/query/query_solution.h
@@ -16,6 +16,7 @@
#pragma once
+#include "mongo/db/matcher/expression.h"
#include "mongo/db/query/stage_types.h"
namespace mongo {
@@ -25,6 +26,7 @@ namespace mongo {
* PlanStages, which can then be handed to a PlanRunner for execution.
*/
struct QuerySolutionNode {
+ QuerySolutionNode() { }
virtual ~QuerySolutionNode() { }
/**
@@ -33,30 +35,61 @@ namespace mongo {
virtual StageType getType() const = 0;
/**
+ * Internal function called by toString()
+ */
+ virtual void appendToString(stringstream* ss) const = 0;
+ private:
+ MONGO_DISALLOW_COPYING(QuerySolutionNode);
+ };
+
+ /**
+ * A QuerySolution must be entirely self-contained and own everything inside of it.
+ *
+ * A tree of stages may be built from a QuerySolution. The QuerySolution must outlive the tree
+ * of stages.
+ */
+ struct QuerySolution {
+ QuerySolution() { }
+
+ // Owned here.
+ scoped_ptr<QuerySolutionNode> root;
+
+ // Owned here.
+ scoped_ptr<MatchExpression> filter;
+
+ // Any filters in root or below point into this. Must be owned.
+ BSONObj filterData;
+
+ /**
* Output a human-readable string representing the plan.
*/
string toString() {
+ if (NULL == root) {
+ return "empty query solution";
+ }
+
stringstream ss;
- appendToString(&ss);
+ root->appendToString(&ss);
return ss.str();
}
-
- /**
- * Internal function called by toString()
- */
- virtual void appendToString(stringstream* ss) const = 0;
+ private:
+ MONGO_DISALLOW_COPYING(QuerySolution);
};
- // The root of the tree is the solution.
- typedef QuerySolutionNode QuerySolution;
+ struct CollectionScanNode : public QuerySolutionNode {
+ CollectionScanNode() : filter(NULL) { }
+
+ virtual StageType getType() const { return STAGE_COLLSCAN; }
- struct EmptyNode : public QuerySolutionNode {
- virtual StageType getType() const { return STAGE_UNKNOWN; }
virtual void appendToString(stringstream* ss) const {
- *ss << "empty?!";
+ *ss << "COLLSCAN ns=" << name << " filter= " << filter->toString() << endl;
}
- };
- // TODO: Implement.
+ string name;
+
+ // Not owned.
+ // This is a sub-tree of the filter in the QuerySolution that owns us.
+ MatchExpression* filter;
+ };
} // namespace mongo