diff options
Diffstat (limited to 'src')
56 files changed, 184 insertions, 159 deletions
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index d43a7242df5..f776a2acaab 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -361,7 +361,7 @@ Status _checkValidFilterExpressions(MatchExpression* expression, int level = 0) default: return Status(ErrorCodes::CannotCreateIndex, str::stream() << "unsupported expression in partial index: " - << expression->toString()); + << expression->debugString()); } } } // namespace diff --git a/src/mongo/db/exec/subplan.cpp b/src/mongo/db/exec/subplan.cpp index bce870afa6e..1a5cda14b3e 100644 --- a/src/mongo/db/exec/subplan.cpp +++ b/src/mongo/db/exec/subplan.cpp @@ -126,7 +126,7 @@ Status SubplanStage::planSubqueries() { auto statusWithCQ = CanonicalQuery::canonicalize(getOpCtx(), *_query, orChild); if (!statusWithCQ.isOK()) { mongoutils::str::stream ss; - ss << "Can't canonicalize subchild " << orChild->toString() << " " + ss << "Can't canonicalize subchild " << orChild->debugString() << " " << statusWithCQ.getStatus().reason(); return Status(ErrorCodes::BadValue, ss); } @@ -195,13 +195,13 @@ Status tagOrChildAccordingToCache(PlanCacheIndexTree* compositeCacheData, if (NULL == branchCacheData) { // For example, we don't cache things for 2d indices. mongoutils::str::stream ss; - ss << "No cache data for subchild " << orChild->toString(); + ss << "No cache data for subchild " << orChild->debugString(); return Status(ErrorCodes::BadValue, ss); } if (SolutionCacheData::USE_INDEX_TAGS_SOLN != branchCacheData->solnType) { mongoutils::str::stream ss; - ss << "No indexed cache data for subchild " << orChild->toString(); + ss << "No indexed cache data for subchild " << orChild->debugString(); return Status(ErrorCodes::BadValue, ss); } @@ -211,7 +211,7 @@ Status tagOrChildAccordingToCache(PlanCacheIndexTree* compositeCacheData, if (!tagStatus.isOK()) { mongoutils::str::stream ss; - ss << "Failed to extract indices from subchild " << orChild->toString(); + ss << "Failed to extract indices from subchild " << orChild->debugString(); return Status(ErrorCodes::BadValue, ss); } @@ -302,13 +302,13 @@ Status SubplanStage::choosePlanForSubqueries(PlanYieldPolicy* yieldPolicy) { // for 2d indices. if (NULL == bestSoln->cacheData.get()) { mongoutils::str::stream ss; - ss << "No cache data for subchild " << orChild->toString(); + ss << "No cache data for subchild " << orChild->debugString(); return Status(ErrorCodes::BadValue, ss); } if (SolutionCacheData::USE_INDEX_TAGS_SOLN != bestSoln->cacheData->solnType) { mongoutils::str::stream ss; - ss << "No indexed cache data for subchild " << orChild->toString(); + ss << "No indexed cache data for subchild " << orChild->debugString(); return Status(ErrorCodes::BadValue, ss); } @@ -318,7 +318,7 @@ Status SubplanStage::choosePlanForSubqueries(PlanYieldPolicy* yieldPolicy) { if (!tagStatus.isOK()) { mongoutils::str::stream ss; - ss << "Failed to extract indices from subchild " << orChild->toString(); + ss << "Failed to extract indices from subchild " << orChild->debugString(); return Status(ErrorCodes::BadValue, ss); } diff --git a/src/mongo/db/matcher/expression.cpp b/src/mongo/db/matcher/expression.cpp index 35bee13f151..364ebdd68d7 100644 --- a/src/mongo/db/matcher/expression.cpp +++ b/src/mongo/db/matcher/expression.cpp @@ -40,18 +40,22 @@ namespace mongo { */ MONGO_FAIL_POINT_DEFINE(disableMatchExpressionOptimization); -using std::string; - MatchExpression::MatchExpression(MatchType type) : _matchType(type) {} -string MatchExpression::toString() const { +std::string MatchExpression::toString() const { BSONObjBuilder bob; serialize(&bob); return bob.obj().toString(); } -void MatchExpression::_debugAddSpace(StringBuilder& debug, int level) const { - for (int i = 0; i < level; i++) +std::string MatchExpression::debugString() const { + StringBuilder builder; + debugString(builder, 0); + return builder.str(); +} + +void MatchExpression::_debugAddSpace(StringBuilder& debug, int indentationLevel) const { + for (int i = 0; i < indentationLevel; i++) debug << " "; } diff --git a/src/mongo/db/matcher/expression.h b/src/mongo/db/matcher/expression.h index 0fb0a2060b4..9607dce1963 100644 --- a/src/mongo/db/matcher/expression.h +++ b/src/mongo/db/matcher/expression.h @@ -309,8 +309,20 @@ public: // // Debug information // - virtual std::string toString() const; - virtual void debugString(StringBuilder& debug, int level = 0) const = 0; + + /** + * Returns a debug string representing the match expression tree, including any tags attached + * for planning. This debug string format may spill across multiple lines, so it is not suitable + * for logging at low debug levels or for error messages. + */ + std::string debugString() const; + virtual void debugString(StringBuilder& debug, int indentationLevel = 0) const = 0; + + /** + * Serializes this MatchExpression to BSON, and then returns a standard string representation of + * the resulting BSON object. + */ + std::string toString() const; protected: /** @@ -330,7 +342,7 @@ protected: virtual void _doAddDependencies(DepsTracker* deps) const {} - void _debugAddSpace(StringBuilder& debug, int level) const; + void _debugAddSpace(StringBuilder& debug, int indentationLevel) const; private: /** diff --git a/src/mongo/db/matcher/expression_always_boolean.h b/src/mongo/db/matcher/expression_always_boolean.h index 4beae6645c1..d638a4b4851 100644 --- a/src/mongo/db/matcher/expression_always_boolean.h +++ b/src/mongo/db/matcher/expression_always_boolean.h @@ -53,8 +53,8 @@ public: return _value; } - void debugString(StringBuilder& debug, int level = 0) const final { - _debugAddSpace(debug, level); + void debugString(StringBuilder& debug, int indentationLevel = 0) const final { + _debugAddSpace(debug, indentationLevel); debug << name() << ": 1\n"; } diff --git a/src/mongo/db/matcher/expression_arity.h b/src/mongo/db/matcher/expression_arity.h index 7975b8517aa..9e1766197b9 100644 --- a/src/mongo/db/matcher/expression_arity.h +++ b/src/mongo/db/matcher/expression_arity.h @@ -53,8 +53,8 @@ public: virtual ~FixedArityMatchExpression() = default; - void debugString(StringBuilder& debug, int level) const final { - _debugAddSpace(debug, level); + void debugString(StringBuilder& debug, int indentationLevel) const final { + _debugAddSpace(debug, indentationLevel); BSONObjBuilder builder; serialize(&builder); diff --git a/src/mongo/db/matcher/expression_array.cpp b/src/mongo/db/matcher/expression_array.cpp index 42e29934623..af7205ef822 100644 --- a/src/mongo/db/matcher/expression_array.cpp +++ b/src/mongo/db/matcher/expression_array.cpp @@ -87,8 +87,8 @@ bool ElemMatchObjectMatchExpression::matchesArray(const BSONObj& anArray, return false; } -void ElemMatchObjectMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void ElemMatchObjectMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " $elemMatch (obj)"; MatchExpression::TagData* td = getTag(); @@ -97,7 +97,7 @@ void ElemMatchObjectMatchExpression::debugString(StringBuilder& debug, int level td->debugString(&debug); } debug << "\n"; - _sub->debugString(debug, level + 1); + _sub->debugString(debug, indentationLevel + 1); } BSONObj ElemMatchObjectMatchExpression::getSerializedRightHandSide() const { @@ -160,8 +160,8 @@ bool ElemMatchValueMatchExpression::_arrayElementMatchesAll(const BSONElement& e return true; } -void ElemMatchValueMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void ElemMatchValueMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " $elemMatch (value)"; MatchExpression::TagData* td = getTag(); @@ -171,7 +171,7 @@ void ElemMatchValueMatchExpression::debugString(StringBuilder& debug, int level) } debug << "\n"; for (unsigned i = 0; i < _subs.size(); i++) { - _subs[i]->debugString(debug, level + 1); + _subs[i]->debugString(debug, indentationLevel + 1); } } @@ -213,8 +213,8 @@ bool SizeMatchExpression::matchesArray(const BSONObj& anArray, MatchDetails* det return anArray.nFields() == _size; } -void SizeMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void SizeMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " $size : " << _size << "\n"; MatchExpression::TagData* td = getTag(); diff --git a/src/mongo/db/matcher/expression_array.h b/src/mongo/db/matcher/expression_array.h index bab018abfc2..471549f105e 100644 --- a/src/mongo/db/matcher/expression_array.h +++ b/src/mongo/db/matcher/expression_array.h @@ -84,7 +84,7 @@ public: return std::move(e); } - virtual void debugString(StringBuilder& debug, int level) const; + virtual void debugString(StringBuilder& debug, int indentationLevel) const; BSONObj getSerializedRightHandSide() const final; @@ -139,7 +139,7 @@ public: return std::move(e); } - virtual void debugString(StringBuilder& debug, int level) const; + virtual void debugString(StringBuilder& debug, int indentationLevel) const; BSONObj getSerializedRightHandSide() const final; @@ -190,7 +190,7 @@ public: virtual bool matchesArray(const BSONObj& anArray, MatchDetails* details) const; - virtual void debugString(StringBuilder& debug, int level) const; + virtual void debugString(StringBuilder& debug, int indentationLevel) const; BSONObj getSerializedRightHandSide() const final; diff --git a/src/mongo/db/matcher/expression_expr.h b/src/mongo/db/matcher/expression_expr.h index 2b25c693016..72c947c2c5b 100644 --- a/src/mongo/db/matcher/expression_expr.h +++ b/src/mongo/db/matcher/expression_expr.h @@ -58,8 +58,8 @@ public: std::unique_ptr<MatchExpression> shallowClone() const final; - void debugString(StringBuilder& debug, int level = 0) const final { - _debugAddSpace(debug, level); + void debugString(StringBuilder& debug, int indentationLevel = 0) const final { + _debugAddSpace(debug, indentationLevel); debug << "$expr " << _expression->serialize(false).toString(); } diff --git a/src/mongo/db/matcher/expression_geo.cpp b/src/mongo/db/matcher/expression_geo.cpp index 0530686631f..b25ee5cf19e 100644 --- a/src/mongo/db/matcher/expression_geo.cpp +++ b/src/mongo/db/matcher/expression_geo.cpp @@ -371,8 +371,8 @@ bool GeoMatchExpression::matchesSingleElement(const BSONElement& e, MatchDetails } } -void GeoMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void GeoMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); BSONObjBuilder builder; serialize(&builder); @@ -433,8 +433,8 @@ bool GeoNearMatchExpression::matchesSingleElement(const BSONElement& e, return true; } -void GeoNearMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void GeoNearMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << "GEONEAR " << _query->toString(); MatchExpression::TagData* td = getTag(); if (NULL != td) { diff --git a/src/mongo/db/matcher/expression_geo.h b/src/mongo/db/matcher/expression_geo.h index c23e87d9271..37f4727bb1a 100644 --- a/src/mongo/db/matcher/expression_geo.h +++ b/src/mongo/db/matcher/expression_geo.h @@ -86,7 +86,7 @@ public: bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final; - virtual void debugString(StringBuilder& debug, int level = 0) const; + virtual void debugString(StringBuilder& debug, int indentationLevel = 0) const; BSONObj getSerializedRightHandSide() const final; @@ -177,7 +177,7 @@ public: */ bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final; - virtual void debugString(StringBuilder& debug, int level = 0) const; + virtual void debugString(StringBuilder& debug, int indentationLevel = 0) const; BSONObj getSerializedRightHandSide() const final; diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp index 1acb218e09d..7327f3c4a86 100644 --- a/src/mongo/db/matcher/expression_leaf.cpp +++ b/src/mongo/db/matcher/expression_leaf.cpp @@ -73,8 +73,8 @@ bool ComparisonMatchExpressionBase::equivalent(const MatchExpression* other) con return path() == realOther->path() && eltCmp.evaluate(_rhs == realOther->_rhs); } -void ComparisonMatchExpressionBase::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void ComparisonMatchExpressionBase::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " " << name(); debug << " " << _rhs.toString(false); @@ -258,8 +258,8 @@ bool RegexMatchExpression::matchesSingleElement(const BSONElement& e, MatchDetai } } -void RegexMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void RegexMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " regex /" << _regex << "/" << _flags; MatchExpression::TagData* td = getTag(); @@ -302,8 +302,8 @@ bool ModMatchExpression::matchesSingleElement(const BSONElement& e, MatchDetails return e.numberLong() % _divisor == _remainder; } -void ModMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void ModMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " mod " << _divisor << " % x == " << _remainder; MatchExpression::TagData* td = getTag(); if (NULL != td) { @@ -336,8 +336,8 @@ bool ExistsMatchExpression::matchesSingleElement(const BSONElement& e, return !e.eoo(); } -void ExistsMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void ExistsMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " exists"; MatchExpression::TagData* td = getTag(); if (NULL != td) { @@ -400,8 +400,8 @@ bool InMatchExpression::matchesSingleElement(const BSONElement& e, MatchDetails* return false; } -void InMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void InMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " $in "; debug << "[ "; for (auto&& equality : _equalitySet) { @@ -721,8 +721,8 @@ bool BitTestMatchExpression::matchesSingleElement(const BSONElement& e, return performBitTest(eValue); } -void BitTestMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void BitTestMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " "; diff --git a/src/mongo/db/matcher/expression_leaf.h b/src/mongo/db/matcher/expression_leaf.h index cfe18e771a6..777614ecdaf 100644 --- a/src/mongo/db/matcher/expression_leaf.h +++ b/src/mongo/db/matcher/expression_leaf.h @@ -104,7 +104,7 @@ public: virtual ~ComparisonMatchExpressionBase() = default; - virtual void debugString(StringBuilder& debug, int level = 0) const; + virtual void debugString(StringBuilder& debug, int indentationLevel = 0) const; BSONObj getSerializedRightHandSide() const final; @@ -308,7 +308,7 @@ public: bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final; - virtual void debugString(StringBuilder& debug, int level) const; + virtual void debugString(StringBuilder& debug, int indentationLevel) const; BSONObj getSerializedRightHandSide() const final; @@ -352,7 +352,7 @@ public: bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final; - virtual void debugString(StringBuilder& debug, int level) const; + virtual void debugString(StringBuilder& debug, int indentationLevel) const; BSONObj getSerializedRightHandSide() const final; @@ -388,7 +388,7 @@ public: bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final; - virtual void debugString(StringBuilder& debug, int level) const; + virtual void debugString(StringBuilder& debug, int indentationLevel) const; BSONObj getSerializedRightHandSide() const final; @@ -411,7 +411,7 @@ public: bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final; - virtual void debugString(StringBuilder& debug, int level) const; + virtual void debugString(StringBuilder& debug, int indentationLevel) const; BSONObj getSerializedRightHandSide() const final; @@ -500,7 +500,7 @@ public: bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final; - virtual void debugString(StringBuilder& debug, int level) const; + virtual void debugString(StringBuilder& debug, int indentationLevel) const; BSONObj getSerializedRightHandSide() const final; diff --git a/src/mongo/db/matcher/expression_text_base.cpp b/src/mongo/db/matcher/expression_text_base.cpp index 16947ffeba6..ea3fa147de2 100644 --- a/src/mongo/db/matcher/expression_text_base.cpp +++ b/src/mongo/db/matcher/expression_text_base.cpp @@ -41,9 +41,9 @@ const bool TextMatchExpressionBase::kDiacriticSensitiveDefault = false; TextMatchExpressionBase::TextMatchExpressionBase(StringData path) : LeafMatchExpression(TEXT, path) {} -void TextMatchExpressionBase::debugString(StringBuilder& debug, int level) const { +void TextMatchExpressionBase::debugString(StringBuilder& debug, int indentationLevel) const { const fts::FTSQuery& ftsQuery = getFTSQuery(); - _debugAddSpace(debug, level); + _debugAddSpace(debug, indentationLevel); debug << "TEXT : query=" << ftsQuery.getQuery() << ", language=" << ftsQuery.getLanguage() << ", caseSensitive=" << ftsQuery.getCaseSensitive() << ", diacriticSensitive=" << ftsQuery.getDiacriticSensitive() << ", tag="; diff --git a/src/mongo/db/matcher/expression_text_base.h b/src/mongo/db/matcher/expression_text_base.h index 507bf4d6acc..a5247930ff5 100644 --- a/src/mongo/db/matcher/expression_text_base.h +++ b/src/mongo/db/matcher/expression_text_base.h @@ -68,7 +68,7 @@ public: // Methods inherited from MatchExpression. // - void debugString(StringBuilder& debug, int level = 0) const final; + void debugString(StringBuilder& debug, int indentationLevel = 0) const final; void serialize(BSONObjBuilder* out) const final; diff --git a/src/mongo/db/matcher/expression_tree.cpp b/src/mongo/db/matcher/expression_tree.cpp index f59849d218d..2cbdb1886f0 100644 --- a/src/mongo/db/matcher/expression_tree.cpp +++ b/src/mongo/db/matcher/expression_tree.cpp @@ -51,9 +51,9 @@ void ListOfMatchExpression::add(MatchExpression* e) { } -void ListOfMatchExpression::_debugList(StringBuilder& debug, int level) const { +void ListOfMatchExpression::_debugList(StringBuilder& debug, int indentationLevel) const { for (unsigned i = 0; i < _expressions.size(); i++) - _expressions[i]->debugString(debug, level + 1); + _expressions[i]->debugString(debug, indentationLevel + 1); } void ListOfMatchExpression::_listToBSON(BSONArrayBuilder* out) const { @@ -215,10 +215,10 @@ bool AndMatchExpression::matchesSingleElement(const BSONElement& e, MatchDetails } -void AndMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void AndMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << "$and\n"; - _debugList(debug, level); + _debugList(debug, indentationLevel); } void AndMatchExpression::serialize(BSONObjBuilder* out) const { @@ -258,10 +258,10 @@ bool OrMatchExpression::matchesSingleElement(const BSONElement& e, MatchDetails* } -void OrMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void OrMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << "$or\n"; - _debugList(debug, level); + _debugList(debug, indentationLevel); } void OrMatchExpression::serialize(BSONObjBuilder* out) const { @@ -300,10 +300,10 @@ bool NorMatchExpression::matchesSingleElement(const BSONElement& e, MatchDetails return true; } -void NorMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void NorMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << "$nor\n"; - _debugList(debug, level); + _debugList(debug, indentationLevel); } void NorMatchExpression::serialize(BSONObjBuilder* out) const { @@ -313,10 +313,10 @@ void NorMatchExpression::serialize(BSONObjBuilder* out) const { // ------- -void NotMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void NotMatchExpression::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << "$not\n"; - _exp->debugString(debug, level + 1); + _exp->debugString(debug, indentationLevel + 1); } boost::optional<StringData> NotMatchExpression::getPathIfNotWithSinglePathMatchExpressionTree( diff --git a/src/mongo/db/matcher/expression_tree.h b/src/mongo/db/matcher/expression_tree.h index 35f9e8bc343..b89efb19461 100644 --- a/src/mongo/db/matcher/expression_tree.h +++ b/src/mongo/db/matcher/expression_tree.h @@ -93,7 +93,7 @@ public: } protected: - void _debugList(StringBuilder& debug, int level) const; + void _debugList(StringBuilder& debug, int indentationLevel) const; void _listToBSON(BSONArrayBuilder* out) const; @@ -125,7 +125,7 @@ public: return std::move(self); } - virtual void debugString(StringBuilder& debug, int level = 0) const; + virtual void debugString(StringBuilder& debug, int indentationLevel = 0) const; virtual void serialize(BSONObjBuilder* out) const; @@ -154,7 +154,7 @@ public: return std::move(self); } - virtual void debugString(StringBuilder& debug, int level = 0) const; + virtual void debugString(StringBuilder& debug, int indentationLevel = 0) const; virtual void serialize(BSONObjBuilder* out) const; @@ -183,7 +183,7 @@ public: return std::move(self); } - virtual void debugString(StringBuilder& debug, int level = 0) const; + virtual void debugString(StringBuilder& debug, int indentationLevel = 0) const; virtual void serialize(BSONObjBuilder* out) const; }; @@ -209,7 +209,7 @@ public: return !_exp->matchesSingleElement(elt, details); } - virtual void debugString(StringBuilder& debug, int level = 0) const; + virtual void debugString(StringBuilder& debug, int indentationLevel = 0) const; virtual void serialize(BSONObjBuilder* out) const; diff --git a/src/mongo/db/matcher/expression_type.h b/src/mongo/db/matcher/expression_type.h index c206103693c..f0820b968bc 100644 --- a/src/mongo/db/matcher/expression_type.h +++ b/src/mongo/db/matcher/expression_type.h @@ -79,8 +79,8 @@ public: return _typeSet.hasType(elem.type()); } - void debugString(StringBuilder& debug, int level) const final { - _debugAddSpace(debug, level); + void debugString(StringBuilder& debug, int indentationLevel) const final { + _debugAddSpace(debug, indentationLevel); debug << path() << " " << name() << ": " << _typeSet.toBSONArray().toString(); MatchExpression::TagData* td = getTag(); @@ -197,8 +197,8 @@ public: return std::move(expr); } - void debugString(StringBuilder& debug, int level) const final { - _debugAddSpace(debug, level); + void debugString(StringBuilder& debug, int indentationLevel) const final { + _debugAddSpace(debug, indentationLevel); debug << path() << " " << name() << ": " << typeName(_binDataSubType); MatchExpression::TagData* td = getTag(); @@ -294,8 +294,8 @@ public: return std::move(expr); } - void debugString(StringBuilder& debug, int level) const final { - _debugAddSpace(debug, level); + void debugString(StringBuilder& debug, int indentationLevel) const final { + _debugAddSpace(debug, indentationLevel); debug << path() << " " << name() << ": " << typeName(_encryptedType); if (auto td = getTag()) { diff --git a/src/mongo/db/matcher/expression_where_base.cpp b/src/mongo/db/matcher/expression_where_base.cpp index 0df2a9c145a..1fe88284a24 100644 --- a/src/mongo/db/matcher/expression_where_base.cpp +++ b/src/mongo/db/matcher/expression_where_base.cpp @@ -38,14 +38,14 @@ namespace mongo { WhereMatchExpressionBase::WhereMatchExpressionBase(WhereParams params) : MatchExpression(WHERE), _code(std::move(params.code)), _scope(std::move(params.scope)) {} -void WhereMatchExpressionBase::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void WhereMatchExpressionBase::debugString(StringBuilder& debug, int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << "$where\n"; - _debugAddSpace(debug, level + 1); + _debugAddSpace(debug, indentationLevel + 1); debug << "code: " << getCode() << "\n"; - _debugAddSpace(debug, level + 1); + _debugAddSpace(debug, indentationLevel + 1); debug << "scope: " << getScope() << "\n"; } diff --git a/src/mongo/db/matcher/expression_where_base.h b/src/mongo/db/matcher/expression_where_base.h index 2f90625fb58..fa7bc6bb632 100644 --- a/src/mongo/db/matcher/expression_where_base.h +++ b/src/mongo/db/matcher/expression_where_base.h @@ -61,7 +61,7 @@ public: return false; } - void debugString(StringBuilder& debug, int level = 0) const final; + void debugString(StringBuilder& debug, int indentationLevel = 0) const final; void serialize(BSONObjBuilder* out) const final; diff --git a/src/mongo/db/matcher/rewrite_expr.cpp b/src/mongo/db/matcher/rewrite_expr.cpp index 3146f9a25d2..c03ba61659f 100644 --- a/src/mongo/db/matcher/rewrite_expr.cpp +++ b/src/mongo/db/matcher/rewrite_expr.cpp @@ -51,9 +51,9 @@ RewriteExpr::RewriteResult RewriteExpr::rewrite(const boost::intrusive_ptr<Expre if (auto matchTree = rewriteExpr._rewriteExpression(expression)) { matchExpression = std::move(matchTree); - LOG(5) << "Post-rewrite MatchExpression: " << matchExpression->toString(); + LOG(5) << "Post-rewrite MatchExpression: " << matchExpression->debugString(); matchExpression = MatchExpression::optimize(std::move(matchExpression)); - LOG(5) << "Post-rewrite/post-optimized MatchExpression: " << matchExpression->toString(); + LOG(5) << "Post-rewrite/post-optimized MatchExpression: " << matchExpression->debugString(); } return {std::move(matchExpression), std::move(rewriteExpr._matchExprElemStorage)}; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp index 2b8d2a7b76d..7c2d67425b0 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp @@ -66,11 +66,11 @@ bool InternalSchemaAllElemMatchFromIndexMatchExpression::equivalent( } void InternalSchemaAllElemMatchFromIndexMatchExpression::debugString(StringBuilder& debug, - int level) const { - _debugAddSpace(debug, level); + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << kName << "\n"; debug << " index: " << _index << ", query:\n"; - _expression->getFilter()->debugString(debug, level + 1); + _expression->getFilter()->debugString(debug, indentationLevel + 1); } BSONObj InternalSchemaAllElemMatchFromIndexMatchExpression::getSerializedRightHandSide() const { diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h index c56884b96bb..dab875cb80d 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h @@ -61,7 +61,7 @@ public: return true; } - void debugString(StringBuilder& debug, int level) const final; + void debugString(StringBuilder& debug, int indentationLevel) const final; BSONObj getSerializedRightHandSide() const final; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp index 733a60c5771..c656840e247 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp @@ -54,8 +54,8 @@ InternalSchemaAllowedPropertiesMatchExpression::InternalSchemaAllowedPropertiesM } void InternalSchemaAllowedPropertiesMatchExpression::debugString(StringBuilder& debug, - int level) const { - _debugAddSpace(debug, level); + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); BSONObjBuilder builder; serialize(&builder); diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h index 5779c4950b8..29042a38aae 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h @@ -115,7 +115,7 @@ public: std::vector<PatternSchema> patternProperties, std::unique_ptr<ExpressionWithPlaceholder> otherwise); - void debugString(StringBuilder& debug, int level) const final; + void debugString(StringBuilder& debug, int indentationLevel) const final; bool equivalent(const MatchExpression* expr) const final; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp index 9f7db2244dd..c28eb69e4fb 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp @@ -53,8 +53,9 @@ bool InternalSchemaEqMatchExpression::matchesSingleElement(const BSONElement& el return _eltCmp.evaluate(_rhsElem == elem); } -void InternalSchemaEqMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void InternalSchemaEqMatchExpression::debugString(StringBuilder& debug, + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " " << kName << " " << _rhsElem.toString(false); auto td = getTag(); diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_eq.h b/src/mongo/db/matcher/schema/expression_internal_schema_eq.h index 7d6406da36c..c2495d991ba 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_eq.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_eq.h @@ -52,7 +52,7 @@ public: bool matchesSingleElement(const BSONElement&, MatchDetails*) const final; - void debugString(StringBuilder& debug, int level) const final; + void debugString(StringBuilder& debug, int indentationLevel) const final; BSONObj getSerializedRightHandSide() const final; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.cpp index 71e954a930f..6362c3e8d41 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.cpp @@ -61,8 +61,9 @@ bool InternalSchemaFmodMatchExpression::matchesSingleElement(const BSONElement& return false; } -void InternalSchemaFmodMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void InternalSchemaFmodMatchExpression::debugString(StringBuilder& debug, + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " fmod: divisor: " << _divisor.toString() << " remainder: " << _remainder.toString(); MatchExpression::TagData* td = getTag(); diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h index 76fb8670c17..201ec23f70e 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h @@ -52,7 +52,7 @@ public: bool matchesSingleElement(const BSONElement& e, MatchDetails* details = nullptr) const final; - void debugString(StringBuilder& debug, int level) const final; + void debugString(StringBuilder& debug, int indentationLevel) const final; BSONObj getSerializedRightHandSide() const final; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp index 7c929a08910..f4264c5d1ef 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp @@ -43,8 +43,8 @@ InternalSchemaMatchArrayIndexMatchExpression::InternalSchemaMatchArrayIndexMatch } void InternalSchemaMatchArrayIndexMatchExpression::debugString(StringBuilder& debug, - int level) const { - _debugAddSpace(debug, level); + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); BSONObjBuilder builder; serialize(&builder); diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h index 89958d3fb82..9a0bb8675b7 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h @@ -45,7 +45,7 @@ public: InternalSchemaMatchArrayIndexMatchExpression( StringData path, long long index, std::unique_ptr<ExpressionWithPlaceholder> expression); - void debugString(StringBuilder& debug, int level) const final; + void debugString(StringBuilder& debug, int indentationLevel) const final; bool equivalent(const MatchExpression* expr) const final; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.cpp index dd4281890d7..c6aa1cf0cca 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.cpp @@ -38,8 +38,8 @@ InternalSchemaNumArrayItemsMatchExpression::InternalSchemaNumArrayItemsMatchExpr : ArrayMatchingMatchExpression(type, path), _name(name), _numItems(numItems) {} void InternalSchemaNumArrayItemsMatchExpression::debugString(StringBuilder& debug, - int level) const { - _debugAddSpace(debug, level); + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " " << _name << " " << _numItems << "\n"; MatchExpression::TagData* td = getTag(); diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h b/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h index 930369c6241..249de09c030 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h @@ -46,7 +46,7 @@ public: virtual ~InternalSchemaNumArrayItemsMatchExpression() {} - void debugString(StringBuilder& debug, int level) const final; + void debugString(StringBuilder& debug, int indentationLevel) const final; BSONObj getSerializedRightHandSide() const final; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.cpp index b62d0a6e889..d8895fc7adb 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.cpp @@ -34,8 +34,8 @@ namespace mongo { void InternalSchemaNumPropertiesMatchExpression::debugString(StringBuilder& debug, - int level) const { - _debugAddSpace(debug, level); + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); BSONObjBuilder builder; serialize(&builder); debug << builder.obj().toString() << "\n"; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h index aad612ec2b4..415ed946145 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h @@ -59,7 +59,7 @@ public: return nullptr; } - void debugString(StringBuilder& debug, int level) const final; + void debugString(StringBuilder& debug, int indentationLevel) const final; void serialize(BSONObjBuilder* out) const final; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp index ab36f871ef3..36a921a4380 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp @@ -51,10 +51,11 @@ bool InternalSchemaObjectMatchExpression::matchesSingleElement(const BSONElement return _sub->matchesBSON(elem.Obj()); } -void InternalSchemaObjectMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void InternalSchemaObjectMatchExpression::debugString(StringBuilder& debug, + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << kName << "\n"; - _sub->debugString(debug, level + 1); + _sub->debugString(debug, indentationLevel + 1); } BSONObj InternalSchemaObjectMatchExpression::getSerializedRightHandSide() const { diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h index 86d80870a97..407c6680057 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h @@ -43,7 +43,7 @@ public: std::unique_ptr<MatchExpression> shallowClone() const final; - void debugString(StringBuilder& debug, int level = 0) const final; + void debugString(StringBuilder& debug, int indentationLevel = 0) const final; BSONObj getSerializedRightHandSide() const final; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp index bea30b7657b..1b1fc6ae29f 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp @@ -40,8 +40,9 @@ bool InternalSchemaRootDocEqMatchExpression::matches(const MatchableDocument* do return _objCmp.evaluate(doc->toBSON() == _rhsObj); } -void InternalSchemaRootDocEqMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void InternalSchemaRootDocEqMatchExpression::debugString(StringBuilder& debug, + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << kName << " " << _rhsObj.toString(); auto td = getTag(); diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h index ea2f411c51a..062d358939d 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h @@ -65,7 +65,7 @@ public: std::unique_ptr<MatchExpression> shallowClone() const final; - void debugString(StringBuilder& debug, int level = 0) const final; + void debugString(StringBuilder& debug, int indentationLevel = 0) const final; void serialize(BSONObjBuilder* out) const final; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_str_length.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_str_length.cpp index 0bf8e45caf7..d8f961ce35b 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_str_length.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_str_length.cpp @@ -41,8 +41,9 @@ InternalSchemaStrLengthMatchExpression::InternalSchemaStrLengthMatchExpression(M StringData name) : LeafMatchExpression(type, path), _name(name), _strLen(strLen) {} -void InternalSchemaStrLengthMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void InternalSchemaStrLengthMatchExpression::debugString(StringBuilder& debug, + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << path() << " " << _name << " " << _strLen << "\n"; MatchExpression::TagData* td = getTag(); diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_str_length.h b/src/mongo/db/matcher/schema/expression_internal_schema_str_length.h index 3fbdd83c1dd..12ade1d8fc0 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_str_length.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_str_length.h @@ -58,7 +58,7 @@ public: return getComparator()(len); }; - void debugString(StringBuilder& debug, int level) const final; + void debugString(StringBuilder& debug, int indentationLevel) const final; BSONObj getSerializedRightHandSide() const final; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp index 2854d58c5d5..afb0a39cbe4 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp @@ -34,8 +34,9 @@ namespace mongo { constexpr StringData InternalSchemaUniqueItemsMatchExpression::kName; -void InternalSchemaUniqueItemsMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void InternalSchemaUniqueItemsMatchExpression::debugString(StringBuilder& debug, + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); BSONObjBuilder builder; serialize(&builder); diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h index f9e9527e6f1..9b47e32682f 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h @@ -71,7 +71,7 @@ public: return true; } - void debugString(StringBuilder& builder, int level) const final; + void debugString(StringBuilder& builder, int indentationLevel) const final; bool equivalent(const MatchExpression* other) const final; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_xor.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_xor.cpp index a876792060a..c920e38f827 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_xor.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_xor.cpp @@ -66,10 +66,11 @@ bool InternalSchemaXorMatchExpression::matchesSingleElement(const BSONElement& e return found; } -void InternalSchemaXorMatchExpression::debugString(StringBuilder& debug, int level) const { - _debugAddSpace(debug, level); +void InternalSchemaXorMatchExpression::debugString(StringBuilder& debug, + int indentationLevel) const { + _debugAddSpace(debug, indentationLevel); debug << kName + "\n"; - _debugList(debug, level); + _debugList(debug, indentationLevel); } void InternalSchemaXorMatchExpression::serialize(BSONObjBuilder* out) const { diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_xor.h b/src/mongo/db/matcher/schema/expression_internal_schema_xor.h index 580524ebe6b..b11d1641a33 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_xor.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_xor.h @@ -58,7 +58,7 @@ public: return std::move(xorCopy); } - void debugString(StringBuilder& debug, int level = 0) const final; + void debugString(StringBuilder& debug, int indentationLevel = 0) const final; void serialize(BSONObjBuilder* out) const final; }; diff --git a/src/mongo/db/matcher/schema/json_schema_parser.cpp b/src/mongo/db/matcher/schema/json_schema_parser.cpp index 2b35d8e34b5..f46196df71f 100644 --- a/src/mongo/db/matcher/schema/json_schema_parser.cpp +++ b/src/mongo/db/matcher/schema/json_schema_parser.cpp @@ -1583,7 +1583,8 @@ StatusWithMatchExpression JSONSchemaParser::parse(BSONObj schema, bool ignoreUnk try { auto translation = _parse(""_sd, schema, ignoreUnknownKeywords); if (shouldLog(logger::LogSeverity::Debug(5)) && translation.isOK()) { - LOG(5) << "Translated schema match expression: " << translation.getValue()->toString(); + LOG(5) << "Translated schema match expression: " + << translation.getValue()->debugString(); } return translation; } catch (const DBException& ex) { diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp index f8661a2fdbc..fa2f522d6de 100644 --- a/src/mongo/db/query/canonical_query.cpp +++ b/src/mongo/db/query/canonical_query.cpp @@ -441,7 +441,7 @@ std::string CanonicalQuery::toString() const { } // The expression tree puts an endl on for us. - ss << "Tree: " << _root->toString(); + ss << "Tree: " << _root->debugString(); ss << "Sort: " << _qr->getSort().toString() << '\n'; ss << "Proj: " << _qr->getProj().toString() << '\n'; if (!_qr->getCollation().isEmpty()) { diff --git a/src/mongo/db/query/canonical_query_test.cpp b/src/mongo/db/query/canonical_query_test.cpp index 1d2138cc581..6afbbfe4d57 100644 --- a/src/mongo/db/query/canonical_query_test.cpp +++ b/src/mongo/db/query/canonical_query_test.cpp @@ -74,8 +74,8 @@ void assertEquivalent(const char* queryStr, } mongoutils::str::stream ss; ss << "Match expressions are not equivalent." - << "\nOriginal query: " << queryStr << "\nExpected: " << expected->toString() - << "\nActual: " << actual->toString(); + << "\nOriginal query: " << queryStr << "\nExpected: " << expected->debugString() + << "\nActual: " << actual->debugString(); FAIL(ss); } @@ -87,8 +87,8 @@ void assertNotEquivalent(const char* queryStr, } mongoutils::str::stream ss; ss << "Match expressions are equivalent." - << "\nOriginal query: " << queryStr << "\nExpected: " << expected->toString() - << "\nActual: " << actual->toString(); + << "\nOriginal query: " << queryStr << "\nExpected: " << expected->debugString() + << "\nActual: " << actual->debugString(); FAIL(ss); } diff --git a/src/mongo/db/query/index_bounds_builder.cpp b/src/mongo/db/query/index_bounds_builder.cpp index f6e1a3841dc..c86a43a5f10 100644 --- a/src/mongo/db/query/index_bounds_builder.cpp +++ b/src/mongo/db/query/index_bounds_builder.cpp @@ -739,7 +739,7 @@ void IndexBoundsBuilder::_translatePredicate(const MatchExpression* expr, } } else { warning() << "Planner error, trying to build bounds for expression: " - << redact(expr->toString()); + << redact(expr->debugString()); verify(0); } } diff --git a/src/mongo/db/query/index_entry.cpp b/src/mongo/db/query/index_entry.cpp index f3af99d36d2..74be2c8ab32 100644 --- a/src/mongo/db/query/index_entry.cpp +++ b/src/mongo/db/query/index_entry.cpp @@ -54,7 +54,7 @@ std::string IndexEntry::toString() const { sb << " name: '" << identifier << "'"; if (filterExpr) { - sb << " filterExpr: " << filterExpr->toString(); + sb << " filterExpr: " << filterExpr->debugString(); } if (!infoObj.isEmpty()) { diff --git a/src/mongo/db/query/plan_cache_test.cpp b/src/mongo/db/query/plan_cache_test.cpp index 903da5cdda2..6cf50b688a1 100644 --- a/src/mongo/db/query/plan_cache_test.cpp +++ b/src/mongo/db/query/plan_cache_test.cpp @@ -234,8 +234,8 @@ void assertEquivalent(const char* queryStr, } str::stream ss; ss << "Match expressions are not equivalent." - << "\nOriginal query: " << queryStr << "\nExpected: " << expected->toString() - << "\nActual: " << actual->toString(); + << "\nOriginal query: " << queryStr << "\nExpected: " << expected->debugString() + << "\nActual: " << actual->debugString(); FAIL(ss); } diff --git a/src/mongo/db/query/plan_enumerator.cpp b/src/mongo/db/query/plan_enumerator.cpp index 2ca15e65bc3..1dbdb6c973d 100644 --- a/src/mongo/db/query/plan_enumerator.cpp +++ b/src/mongo/db/query/plan_enumerator.cpp @@ -308,11 +308,12 @@ string PlanEnumerator::NodeAssignment::toString() const { ss << "\t\tidx[" << oie.index << "]\n"; for (size_t k = 0; k < oie.preds.size(); ++k) { - ss << "\t\t\tpos " << oie.positions[k] << " pred " << oie.preds[k]->toString(); + ss << "\t\t\tpos " << oie.positions[k] << " pred " + << oie.preds[k]->debugString(); } for (auto&& pushdown : oie.orPushdowns) { - ss << "\t\torPushdownPred: " << pushdown.first->toString(); + ss << "\t\torPushdownPred: " << pushdown.first->debugString(); } } } diff --git a/src/mongo/db/query/planner_ixselect.cpp b/src/mongo/db/query/planner_ixselect.cpp index 7383659e7f6..1f314787fdb 100644 --- a/src/mongo/db/query/planner_ixselect.cpp +++ b/src/mongo/db/query/planner_ixselect.cpp @@ -574,7 +574,7 @@ bool QueryPlannerIXSelect::_compatible(const BSONElement& keyPatternElt, } else if (IndexNames::GEO_HAYSTACK == indexedFieldType) { return false; } else { - warning() << "Unknown indexing for node " << node->toString() << " and field " + warning() << "Unknown indexing for node " << node->debugString() << " and field " << keyPatternElt.toString(); verify(0); } diff --git a/src/mongo/db/query/planner_ixselect_test.cpp b/src/mongo/db/query/planner_ixselect_test.cpp index ff4149b5dcf..1f021e13d6e 100644 --- a/src/mongo/db/query/planner_ixselect_test.cpp +++ b/src/mongo/db/query/planner_ixselect_test.cpp @@ -174,7 +174,7 @@ void findRelevantTaggedNodePathsAndIndices(MatchExpression* root, RelevantTag* r = dynamic_cast<RelevantTag*>(tag); if (!r) { mongoutils::str::stream ss; - ss << "tag is not instance of RelevantTag. tree: " << root->toString() + ss << "tag is not instance of RelevantTag. tree: " << root->debugString() << "; tag: " << buf.str(); FAIL(ss); } diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp index 34cc90bcb8d..0a45ee45dca 100644 --- a/src/mongo/db/query/query_planner.cpp +++ b/src/mongo/db/query/query_planner.cpp @@ -478,7 +478,7 @@ StatusWith<std::unique_ptr<QuerySolution>> QueryPlanner::planFromCache( LOG(5) << "Tagging the match expression according to cache data: " << endl << "Filter:" << endl - << redact(clone->toString()) << "Cache data:" << endl + << redact(clone->debugString()) << "Cache data:" << endl << redact(winnerCacheData.toString()); stdx::unordered_set<string> fields; @@ -504,7 +504,7 @@ StatusWith<std::unique_ptr<QuerySolution>> QueryPlanner::planFromCache( // The MatchExpression tree is in canonical order. We must order the nodes for access planning. prepareForAccessPlanning(clone.get()); - LOG(5) << "Tagged tree:" << endl << redact(clone->toString()); + LOG(5) << "Tagged tree:" << endl << redact(clone->debugString()); // Use the cached index assignments to build solnRoot. std::unique_ptr<QuerySolutionNode> solnRoot(QueryPlannerAccess::buildIndexedDataAccess( @@ -726,7 +726,7 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan( } // query.root() is now annotated with RelevantTag(s). - LOG(5) << "Rated tree:" << endl << redact(query.root()->toString()); + LOG(5) << "Rated tree:" << endl << redact(query.root()->debugString()); // If there is a GEO_NEAR it must have an index it can use directly. const MatchExpression* gnNode = NULL; @@ -740,7 +740,7 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan( return Status(ErrorCodes::BadValue, "unable to find index for $geoNear query"); } - LOG(5) << "Rated tree after geonear processing:" << redact(query.root()->toString()); + LOG(5) << "Rated tree after geonear processing:" << redact(query.root()->debugString()); } // Likewise, if there is a TEXT it must have an index it can use directly. @@ -776,7 +776,7 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan( // assigned to it. invariant(1 == tag->first.size() + tag->notFirst.size()); - LOG(5) << "Rated tree after text processing:" << redact(query.root()->toString()); + LOG(5) << "Rated tree after text processing:" << redact(query.root()->debugString()); } // If we have any relevant indices, we try to create indexed plans. @@ -793,7 +793,7 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan( unique_ptr<MatchExpression> nextTaggedTree; while ((nextTaggedTree = isp.getNext()) && (out.size() < params.maxIndexedSolutions)) { LOG(5) << "About to build solntree from tagged tree:" << endl - << redact(nextTaggedTree->toString()); + << redact(nextTaggedTree->debugString()); // Store the plan cache index tree before calling prepareForAccessingPlanning(), so that // the PlanCacheIndexTree has the same sort as the MatchExpression used to generate the diff --git a/src/mongo/db/query/query_solution.cpp b/src/mongo/db/query/query_solution.cpp index 41964470d6a..dd0be890782 100644 --- a/src/mongo/db/query/query_solution.cpp +++ b/src/mongo/db/query/query_solution.cpp @@ -205,7 +205,7 @@ void TextNode::appendToString(mongoutils::str::stream* ss, int indent) const { *ss << "indexPrefix = " << indexPrefix.toString() << '\n'; if (NULL != filter) { addIndent(ss, indent + 1); - *ss << " filter = " << filter->toString(); + *ss << " filter = " << filter->debugString(); } addCommon(ss, indent); } @@ -235,7 +235,7 @@ void CollectionScanNode::appendToString(mongoutils::str::stream* ss, int indent) *ss << "ns = " << name << '\n'; if (NULL != filter) { addIndent(ss, indent + 1); - *ss << "filter = " << filter->toString(); + *ss << "filter = " << filter->debugString(); } addCommon(ss, indent); } @@ -267,7 +267,7 @@ void AndHashNode::appendToString(mongoutils::str::stream* ss, int indent) const *ss << "AND_HASH\n"; if (NULL != filter) { addIndent(ss, indent + 1); - *ss << " filter = " << filter->toString() << '\n'; + *ss << " filter = " << filter->debugString() << '\n'; } addCommon(ss, indent); for (size_t i = 0; i < children.size(); ++i) { @@ -371,7 +371,7 @@ void OrNode::appendToString(mongoutils::str::stream* ss, int indent) const { *ss << "OR\n"; if (NULL != filter) { addIndent(ss, indent + 1); - *ss << " filter = " << filter->toString() << '\n'; + *ss << " filter = " << filter->debugString() << '\n'; } addCommon(ss, indent); for (size_t i = 0; i < children.size(); ++i) { @@ -432,7 +432,7 @@ void MergeSortNode::appendToString(mongoutils::str::stream* ss, int indent) cons *ss << "MERGE_SORT\n"; if (NULL != filter) { addIndent(ss, indent + 1); - *ss << " filter = " << filter->toString() << '\n'; + *ss << " filter = " << filter->debugString() << '\n'; } addCommon(ss, indent); for (size_t i = 0; i < children.size(); ++i) { @@ -531,7 +531,7 @@ void IndexScanNode::appendToString(mongoutils::str::stream* ss, int indent) cons *ss << "keyPattern = " << index.keyPattern << '\n'; if (NULL != filter) { addIndent(ss, indent + 1); - *ss << "filter = " << filter->toString(); + *ss << "filter = " << filter->debugString(); } addIndent(ss, indent + 1); *ss << "direction = " << direction << '\n'; @@ -1043,7 +1043,7 @@ void GeoNear2DNode::appendToString(mongoutils::str::stream* ss, int indent) cons *ss << "nearQuery = " << nq->toString() << '\n'; if (NULL != filter) { addIndent(ss, indent + 1); - *ss << " filter = " << filter->toString(); + *ss << " filter = " << filter->debugString(); } } @@ -1077,7 +1077,7 @@ void GeoNear2DSphereNode::appendToString(mongoutils::str::stream* ss, int indent *ss << "nearQuery = " << nq->toString() << '\n'; if (NULL != filter) { addIndent(ss, indent + 1); - *ss << " filter = " << filter->toString(); + *ss << " filter = " << filter->debugString(); } } |