summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/parsed_projection.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/parsed_projection.h')
-rw-r--r--src/mongo/db/query/parsed_projection.h214
1 files changed, 107 insertions, 107 deletions
diff --git a/src/mongo/db/query/parsed_projection.h b/src/mongo/db/query/parsed_projection.h
index 3fa40fe2ca8..b135b5f47ed 100644
--- a/src/mongo/db/query/parsed_projection.h
+++ b/src/mongo/db/query/parsed_projection.h
@@ -32,112 +32,112 @@
namespace mongo {
- class ParsedProjection {
- public:
- // TODO: this is duplicated in here and in the proj exec code. When we have
- // ProjectionExpression we can remove dups.
- enum ArrayOpType {
- ARRAY_OP_NORMAL = 0,
- ARRAY_OP_ELEM_MATCH,
- ARRAY_OP_POSITIONAL
- };
-
- /**
- * Parses the projection 'spec' and checks its validity with respect to the query 'query'.
- * Puts covering information into 'out'.
- *
- * Returns Status::OK() if it's a valid spec.
- * Returns a Status indicating how it's invalid otherwise.
- */
- static Status make(const BSONObj& spec,
- const MatchExpression* const query,
- ParsedProjection** out,
- const MatchExpressionParser::WhereCallback& whereCallback =
- MatchExpressionParser::WhereCallback());
-
- /**
- * Returns true if the projection requires match details from the query,
- * and false otherwise.
- */
- bool requiresMatchDetails() const { return _requiresMatchDetails; }
-
- /**
- * Is the full document required to compute this projection?
- */
- bool requiresDocument() const { return _requiresDocument; }
-
- /**
- * If requiresDocument() == false, what fields are required to compute
- * the projection?
- */
- const std::vector<std::string>& getRequiredFields() const {
- return _requiredFields;
- }
-
- /**
- * Get the raw BSONObj proj spec obj
- */
- const BSONObj& getProjObj() const {
- return _source;
- }
-
- /**
- * Does the projection want geoNear metadata? If so any geoNear stage should include them.
- */
- bool wantGeoNearDistance() const {
- return _wantGeoNearDistance;
- }
-
- bool wantGeoNearPoint() const {
- return _wantGeoNearPoint;
- }
-
- bool wantIndexKey() const {
- return _returnKey;
- }
-
- private:
- /**
- * Must go through ::make
- */
- ParsedProjection()
- : _requiresMatchDetails(false),
- _requiresDocument(true),
- _wantGeoNearDistance(false),
- _wantGeoNearPoint(false),
- _returnKey(false) { }
-
- /**
- * Returns true if field name refers to a positional projection.
- */
- static bool _isPositionalOperator(const char* fieldName);
-
- /**
- * Returns true if the MatchExpression 'query' queries against
- * the field named by 'matchfield'. This deeply traverses logical
- * nodes in the matchfield and returns true if any of the children
- * have the field (so if 'query' is {$and: [{a: 1}, {b: 1}]} and
- * 'matchfield' is "b", the return value is true).
- *
- * Does not take ownership of 'query'.
- */
- static bool _hasPositionalOperatorMatch(const MatchExpression* const query,
- const std::string& matchfield);
-
- // TODO: stringdata?
- std::vector<std::string> _requiredFields;
-
- bool _requiresMatchDetails;
-
- bool _requiresDocument;
-
- BSONObj _source;
-
- bool _wantGeoNearDistance;
-
- bool _wantGeoNearPoint;
-
- bool _returnKey;
- };
+class ParsedProjection {
+public:
+ // TODO: this is duplicated in here and in the proj exec code. When we have
+ // ProjectionExpression we can remove dups.
+ enum ArrayOpType { ARRAY_OP_NORMAL = 0, ARRAY_OP_ELEM_MATCH, ARRAY_OP_POSITIONAL };
+
+ /**
+ * Parses the projection 'spec' and checks its validity with respect to the query 'query'.
+ * Puts covering information into 'out'.
+ *
+ * Returns Status::OK() if it's a valid spec.
+ * Returns a Status indicating how it's invalid otherwise.
+ */
+ static Status make(const BSONObj& spec,
+ const MatchExpression* const query,
+ ParsedProjection** out,
+ const MatchExpressionParser::WhereCallback& whereCallback =
+ MatchExpressionParser::WhereCallback());
+
+ /**
+ * Returns true if the projection requires match details from the query,
+ * and false otherwise.
+ */
+ bool requiresMatchDetails() const {
+ return _requiresMatchDetails;
+ }
+
+ /**
+ * Is the full document required to compute this projection?
+ */
+ bool requiresDocument() const {
+ return _requiresDocument;
+ }
+
+ /**
+ * If requiresDocument() == false, what fields are required to compute
+ * the projection?
+ */
+ const std::vector<std::string>& getRequiredFields() const {
+ return _requiredFields;
+ }
+
+ /**
+ * Get the raw BSONObj proj spec obj
+ */
+ const BSONObj& getProjObj() const {
+ return _source;
+ }
+
+ /**
+ * Does the projection want geoNear metadata? If so any geoNear stage should include them.
+ */
+ bool wantGeoNearDistance() const {
+ return _wantGeoNearDistance;
+ }
+
+ bool wantGeoNearPoint() const {
+ return _wantGeoNearPoint;
+ }
+
+ bool wantIndexKey() const {
+ return _returnKey;
+ }
+
+private:
+ /**
+ * Must go through ::make
+ */
+ ParsedProjection()
+ : _requiresMatchDetails(false),
+ _requiresDocument(true),
+ _wantGeoNearDistance(false),
+ _wantGeoNearPoint(false),
+ _returnKey(false) {}
+
+ /**
+ * Returns true if field name refers to a positional projection.
+ */
+ static bool _isPositionalOperator(const char* fieldName);
+
+ /**
+ * Returns true if the MatchExpression 'query' queries against
+ * the field named by 'matchfield'. This deeply traverses logical
+ * nodes in the matchfield and returns true if any of the children
+ * have the field (so if 'query' is {$and: [{a: 1}, {b: 1}]} and
+ * 'matchfield' is "b", the return value is true).
+ *
+ * Does not take ownership of 'query'.
+ */
+ static bool _hasPositionalOperatorMatch(const MatchExpression* const query,
+ const std::string& matchfield);
+
+ // TODO: stringdata?
+ std::vector<std::string> _requiredFields;
+
+ bool _requiresMatchDetails;
+
+ bool _requiresDocument;
+
+ BSONObj _source;
+
+ bool _wantGeoNearDistance;
+
+ bool _wantGeoNearPoint;
+
+ bool _returnKey;
+};
} // namespace mongo