summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_algo.h
diff options
context:
space:
mode:
authorBenjamin Murphy <benjamin_murphy@me.com>2016-03-31 16:53:32 -0400
committerBenjamin Murphy <benjamin_murphy@me.com>2016-04-25 17:07:06 -0400
commit3e9149a2db5a6d2e2ecf262340dc052d4dfaaea8 (patch)
tree0188db11feca56f14d93de1bd671d73e9d7be7e0 /src/mongo/db/matcher/expression_algo.h
parenta23916029eb90e7257edf881a30d6d56fb9687de (diff)
downloadmongo-3e9149a2db5a6d2e2ecf262340dc052d4dfaaea8.tar.gz
SERVER-21612 Reorder lookup and match.
Diffstat (limited to 'src/mongo/db/matcher/expression_algo.h')
-rw-r--r--src/mongo/db/matcher/expression_algo.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mongo/db/matcher/expression_algo.h b/src/mongo/db/matcher/expression_algo.h
index 0b377830274..c8747acac33 100644
--- a/src/mongo/db/matcher/expression_algo.h
+++ b/src/mongo/db/matcher/expression_algo.h
@@ -28,12 +28,17 @@
* it in the license file.
*/
+#include "mongo/stdx/functional.h"
+
namespace mongo {
class MatchExpression;
+struct DepsTracker;
namespace expression {
+using NodeTraversalFunc = stdx::function<void(MatchExpression*, std::string)>;
+
/**
* Returns true if the documents matched by 'lhs' are a subset of the documents matched by
* 'rhs', i.e. a document matched by 'lhs' must also be matched by 'rhs', and false otherwise.
@@ -75,6 +80,24 @@ bool isSplittableBy(const MatchExpression& expr, const std::set<std::string>& pa
bool isIndependentOf(const MatchExpression& expr, const std::set<std::string>& pathSet);
/**
+ * Returns whether the path represented by 'first' is an prefix of the path represented by 'second'.
+ * Equality is not considered a prefix. For example:
+ *
+ * a.b is a prefix of a.b.c
+ * a.b is not a prefix of a.balloon
+ * a is a prefix of a.b
+ * a is not a prefix of a
+ * a.b is not a prefix of a
+ */
+bool isPathPrefixOf(StringData first, StringData second);
+
+/**
+ * Applies 'func' to each node of 'expr', where the first argument is a pointer to that actual node
+ * (not a copy), and the second argument is the path to that node.
+ */
+void mapOver(MatchExpression* expr, NodeTraversalFunc func, std::string path = "");
+
+/**
* Attempt to split 'expr' into two MatchExpressions, where the first is not reliant upon any
* path from 'fields', such that applying the matches in sequence is equivalent to applying
* 'expr'. Takes ownership of 'expr'.