summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/dependencies.h
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2017-08-28 15:10:42 -0400
committerCharlie Swanson <charlie.swanson@mongodb.com>2017-09-01 15:36:35 -0400
commitbc3e230523e4677e2f3fed64ea89c369182a9272 (patch)
treebb35904e784f224e6d5ab87b508c69c72f447dd3 /src/mongo/db/pipeline/dependencies.h
parent4e01e3582541fc00ec2e83c97cac89b59fbfeb34 (diff)
downloadmongo-bc3e230523e4677e2f3fed64ea89c369182a9272.tar.gz
SERVER-30704 Use ARM to merge agg cursors on mongos.
Diffstat (limited to 'src/mongo/db/pipeline/dependencies.h')
-rw-r--r--src/mongo/db/pipeline/dependencies.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/mongo/db/pipeline/dependencies.h b/src/mongo/db/pipeline/dependencies.h
index 9afd9adbaec..19cf3ee33f8 100644
--- a/src/mongo/db/pipeline/dependencies.h
+++ b/src/mongo/db/pipeline/dependencies.h
@@ -47,7 +47,7 @@ struct DepsTracker {
enum MetadataAvailable { kNoMetadata = 0, kTextScore = 1 };
DepsTracker(MetadataAvailable metadataAvailable = kNoMetadata)
- : needWholeDocument(false), _metadataAvailable(metadataAvailable), _needTextScore(false) {}
+ : _metadataAvailable(metadataAvailable) {}
/**
* Returns a projection object covering the dependencies tracked by this class.
@@ -56,10 +56,6 @@ struct DepsTracker {
boost::optional<ParsedDeps> toParsedDeps() const;
- std::set<std::string> fields; // names of needed fields in dotted notation
- bool needWholeDocument; // if true, ignore fields and assume the whole document is needed
-
-
bool hasNoRequirements() const {
return fields.empty() && !needWholeDocument && !_needTextScore;
}
@@ -85,9 +81,29 @@ struct DepsTracker {
_needTextScore = needTextScore;
}
+ bool getNeedSortKey() const {
+ return _needSortKey;
+ }
+
+ void setNeedSortKey(bool needSortKey) {
+ // We don't expect to ever unset '_needSortKey'.
+ invariant(!_needSortKey || needSortKey);
+ _needSortKey = needSortKey;
+ }
+
+ std::set<std::string> fields; // The names of needed fields in dotted notation.
+ bool needWholeDocument = false; // If true, ignore 'fields' and assume the whole document is
+ // needed.
private:
+ /**
+ * Appends the meta projections for the sort key and/or text score to 'bb' if necessary. Returns
+ * true if either type of metadata was needed, and false otherwise.
+ */
+ bool _appendMetaProjections(BSONObjBuilder* bb) const;
+
MetadataAvailable _metadataAvailable;
- bool _needTextScore;
+ bool _needTextScore = false; // if true, add a {$meta: "textScore"} to the projection.
+ bool _needSortKey = false; // if true, add a {$meta: "sortKey"} to the projection.
};
/**