diff options
author | David Storch <david.storch@10gen.com> | 2017-08-01 15:40:36 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2017-08-02 16:54:56 -0400 |
commit | 0334cb2bf602ec0123594b59504b9b3e0a099899 (patch) | |
tree | 432c8463e9e7273ec2f11978c5dcbc47e363ba84 /src/mongo/db/matcher/expression_array.cpp | |
parent | f38554ab9fd611bb798812e4eb1fa7e3d3bbb7e3 (diff) | |
download | mongo-0334cb2bf602ec0123594b59504b9b3e0a099899.tar.gz |
SERVER-30245 Make ArrayMatchingMatchExpression inherit from PathMatchExpression.
Diffstat (limited to 'src/mongo/db/matcher/expression_array.cpp')
-rw-r--r-- | src/mongo/db/matcher/expression_array.cpp | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/src/mongo/db/matcher/expression_array.cpp b/src/mongo/db/matcher/expression_array.cpp index 965ab75d119..b80e321b976 100644 --- a/src/mongo/db/matcher/expression_array.cpp +++ b/src/mongo/db/matcher/expression_array.cpp @@ -35,39 +35,13 @@ namespace mongo { -Status ArrayMatchingMatchExpression::setPath(StringData path) { - _path = path; - Status s = _elementPath.init(_path); - _elementPath.setTraverseLeafArray(false); - return s; -} - -bool ArrayMatchingMatchExpression::matches(const MatchableDocument* doc, - MatchDetails* details) const { - MatchableDocument::IteratorHolder cursor(doc, &_elementPath); - - while (cursor->more()) { - ElementIterator::Context e = cursor->next(); - if (e.element().type() != Array) - continue; - - bool amIRoot = e.arrayOffset().eoo(); - - if (!matchesArray(e.element().Obj(), amIRoot ? details : NULL)) - continue; - - if (!amIRoot && details && details->needRecord() && !e.arrayOffset().eoo()) { - details->setElemMatchKey(e.arrayOffset().fieldName()); - } - return true; +bool ArrayMatchingMatchExpression::matchesSingleElement(const BSONElement& elt, + MatchDetails* details) const { + if (elt.type() != BSONType::Array) { + return false; } - return false; -} -bool ArrayMatchingMatchExpression::matchesSingleElement(const BSONElement& e) const { - if (e.type() != Array) - return false; - return matchesArray(e.Obj(), NULL); + return matchesArray(elt.embeddedObject(), details); } @@ -78,7 +52,7 @@ bool ArrayMatchingMatchExpression::equivalent(const MatchExpression* other) cons const ArrayMatchingMatchExpression* realOther = static_cast<const ArrayMatchingMatchExpression*>(other); - if (_path != realOther->_path) + if (path() != realOther->path()) return false; if (numChildren() != realOther->numChildren()) |