diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2019-04-08 16:27:50 -0400 |
---|---|---|
committer | Billy Donahue <billy.donahue@mongodb.com> | 2019-04-09 15:38:40 -0400 |
commit | 1041dd848e25e879260d1015d8da4f72ee7993fe (patch) | |
tree | f8ddb4ee7c841e4ef790ea7bd53e75c0a09c4cc2 /src/mongo/db/query | |
parent | 8cdc51e7810f7fd8898a4c60b935e389f04659ee (diff) | |
download | mongo-1041dd848e25e879260d1015d8da4f72ee7993fe.tar.gz |
SERVER-40476 remove mongoutils::str
Rename utils/mongoutils/str.h => utils/str.h
Rename namespace mongoutils::str => str
Rename mongo::strcasecmp => str::caseInsensitiveCompare.
Diffstat (limited to 'src/mongo/db/query')
29 files changed, 111 insertions, 115 deletions
diff --git a/src/mongo/db/query/canonical_query_test.cpp b/src/mongo/db/query/canonical_query_test.cpp index 6afbbfe4d57..8926ce0dd2d 100644 --- a/src/mongo/db/query/canonical_query_test.cpp +++ b/src/mongo/db/query/canonical_query_test.cpp @@ -57,7 +57,7 @@ MatchExpression* parseMatchExpression(const BSONObj& obj) { ExtensionsCallbackNoop(), MatchExpressionParser::kAllowAllSpecialFeatures); if (!status.isOK()) { - mongoutils::str::stream ss; + str::stream ss; ss << "failed to parse query: " << obj.toString() << ". Reason: " << status.getStatus().toString(); FAIL(ss); @@ -72,7 +72,7 @@ void assertEquivalent(const char* queryStr, if (actual->equivalent(expected)) { return; } - mongoutils::str::stream ss; + str::stream ss; ss << "Match expressions are not equivalent." << "\nOriginal query: " << queryStr << "\nExpected: " << expected->debugString() << "\nActual: " << actual->debugString(); @@ -85,7 +85,7 @@ void assertNotEquivalent(const char* queryStr, if (!actual->equivalent(expected)) { return; } - mongoutils::str::stream ss; + str::stream ss; ss << "Match expressions are equivalent." << "\nOriginal query: " << queryStr << "\nExpected: " << expected->debugString() << "\nActual: " << actual->debugString(); diff --git a/src/mongo/db/query/collation/collator_factory_icu.cpp b/src/mongo/db/query/collation/collator_factory_icu.cpp index 8c232d60025..c8b8de7a5ab 100644 --- a/src/mongo/db/query/collation/collator_factory_icu.cpp +++ b/src/mongo/db/query/collation/collator_factory_icu.cpp @@ -40,7 +40,7 @@ #include "mongo/bson/util/bson_extract.h" #include "mongo/db/query/collation/collator_interface_icu.h" #include "mongo/stdx/memory.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" namespace mongo { diff --git a/src/mongo/db/query/count_request.cpp b/src/mongo/db/query/count_request.cpp index 733287b0e15..77c8b82b211 100644 --- a/src/mongo/db/query/count_request.cpp +++ b/src/mongo/db/query/count_request.cpp @@ -32,7 +32,7 @@ #include "mongo/db/query/count_request.h" #include "mongo/db/query/query_request.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" namespace mongo { namespace { diff --git a/src/mongo/db/query/count_request_test.cpp b/src/mongo/db/query/count_request_test.cpp index e81877a07f8..21225033d07 100644 --- a/src/mongo/db/query/count_request_test.cpp +++ b/src/mongo/db/query/count_request_test.cpp @@ -35,7 +35,7 @@ #include "mongo/db/pipeline/aggregation_request.h" #include "mongo/db/query/count_request.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" namespace mongo { namespace { diff --git a/src/mongo/db/query/datetime/date_time_support.cpp b/src/mongo/db/query/datetime/date_time_support.cpp index c3325351158..01397b1c605 100644 --- a/src/mongo/db/query/datetime/date_time_support.cpp +++ b/src/mongo/db/query/datetime/date_time_support.cpp @@ -43,7 +43,7 @@ #include "mongo/util/assert_util.h" #include "mongo/util/duration.h" #include "mongo/util/log.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" namespace mongo { diff --git a/src/mongo/db/query/datetime/init_timezone_data.cpp b/src/mongo/db/query/datetime/init_timezone_data.cpp index 2097b9c4f27..dea7322dd90 100644 --- a/src/mongo/db/query/datetime/init_timezone_data.cpp +++ b/src/mongo/db/query/datetime/init_timezone_data.cpp @@ -36,7 +36,7 @@ #include "mongo/db/server_options.h" #include "mongo/db/service_context.h" #include "mongo/stdx/memory.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" namespace mongo { namespace { diff --git a/src/mongo/db/query/explain.cpp b/src/mongo/db/query/explain.cpp index 0b6ac374326..8eecde1fad1 100644 --- a/src/mongo/db/query/explain.cpp +++ b/src/mongo/db/query/explain.cpp @@ -53,8 +53,8 @@ #include "mongo/db/query/stage_builder.h" #include "mongo/db/server_options.h" #include "mongo/util/hex.h" -#include "mongo/util/mongoutils/str.h" #include "mongo/util/net/socket_utils.h" +#include "mongo/util/str.h" #include "mongo/util/version.h" namespace { @@ -296,7 +296,7 @@ unique_ptr<PlanStageStats> getWinningPlanStatsTree(const PlanExecutor* exec) { namespace mongo { -using mongoutils::str::stream; +using str::stream; // static void Explain::statsToBSON(const PlanStageStats& stats, diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp index 7133be046d5..ce24825218a 100644 --- a/src/mongo/db/query/find.cpp +++ b/src/mongo/db/query/find.cpp @@ -65,8 +65,8 @@ #include "mongo/stdx/memory.h" #include "mongo/util/fail_point_service.h" #include "mongo/util/log.h" -#include "mongo/util/mongoutils/str.h" #include "mongo/util/scopeguard.h" +#include "mongo/util/str.h" namespace mongo { diff --git a/src/mongo/db/query/get_executor_test.cpp b/src/mongo/db/query/get_executor_test.cpp index be61a15fcb5..50b50275a4c 100644 --- a/src/mongo/db/query/get_executor_test.cpp +++ b/src/mongo/db/query/get_executor_test.cpp @@ -42,7 +42,7 @@ #include "mongo/db/query/query_test_service_context.h" #include "mongo/stdx/unordered_set.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" using namespace mongo; diff --git a/src/mongo/db/query/index_bounds.cpp b/src/mongo/db/query/index_bounds.cpp index b76e083d7a1..929f73368f3 100644 --- a/src/mongo/db/query/index_bounds.cpp +++ b/src/mongo/db/query/index_bounds.cpp @@ -127,7 +127,7 @@ bool IndexBounds::operator!=(const IndexBounds& other) const { } string OrderedIntervalList::toString() const { - mongoutils::str::stream ss; + str::stream ss; ss << "['" << name << "']: "; for (size_t j = 0; j < intervals.size(); ++j) { ss << intervals[j].toString(); @@ -297,7 +297,7 @@ void OrderedIntervalList::complement() { } string IndexBounds::toString() const { - mongoutils::str::stream ss; + str::stream ss; if (isSimpleRange) { if (IndexBounds::isStartIncludedInBound(boundInclusion)) { ss << "["; diff --git a/src/mongo/db/query/index_bounds_builder.cpp b/src/mongo/db/query/index_bounds_builder.cpp index 43c5a55772c..bd3c92c38fc 100644 --- a/src/mongo/db/query/index_bounds_builder.cpp +++ b/src/mongo/db/query/index_bounds_builder.cpp @@ -50,7 +50,7 @@ #include "mongo/db/query/planner_wildcard_helpers.h" #include "mongo/db/query/query_knobs_gen.h" #include "mongo/util/log.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" #include "third_party/s2/s2cell.h" #include "third_party/s2/s2regioncoverer.h" @@ -194,7 +194,7 @@ string IndexBoundsBuilder::simpleRegex(const char* regex, } } - mongoutils::str::stream ss; + str::stream ss; string r = ""; while (*regex) { diff --git a/src/mongo/db/query/index_bounds_test.cpp b/src/mongo/db/query/index_bounds_test.cpp index fee6d873365..beded95e98a 100644 --- a/src/mongo/db/query/index_bounds_test.cpp +++ b/src/mongo/db/query/index_bounds_test.cpp @@ -38,7 +38,7 @@ #include "mongo/db/query/index_bounds.h" #include "mongo/unittest/unittest.h" #include "mongo/util/assert_util.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" #include "mongo/util/text.h" using namespace mongo; @@ -981,7 +981,7 @@ void testFindIntervalForField(int key, IndexBoundsChecker::Location location = IndexBoundsChecker::findIntervalForField(keyElt, oil, expectedDirection, &intervalIndex); if (expectedLocation != location) { - mongoutils::str::stream ss; + str::stream ss; ss << "Unexpected location from findIntervalForField: key=" << keyElt << "; intervals=" << oil.toString() << "; direction=" << expectedDirection << ". Expected: " << toString(expectedLocation) << ". Actual: " << toString(location); @@ -991,7 +991,7 @@ void testFindIntervalForField(int key, if ((IndexBoundsChecker::BEHIND == expectedLocation || IndexBoundsChecker::WITHIN == expectedLocation) && expectedIntervalIndex != intervalIndex) { - mongoutils::str::stream ss; + str::stream ss; ss << "Unexpected interval index from findIntervalForField: key=" << keyElt << "; intervals=" << oil.toString() << "; direction=" << expectedDirection << "; location= " << toString(location) << ". Expected: " << expectedIntervalIndex diff --git a/src/mongo/db/query/index_entry.h b/src/mongo/db/query/index_entry.h index 5595de03fb4..89b14ffd609 100644 --- a/src/mongo/db/query/index_entry.h +++ b/src/mongo/db/query/index_entry.h @@ -37,7 +37,7 @@ #include "mongo/db/index/multikey_paths.h" #include "mongo/db/index_names.h" #include "mongo/db/jsobj.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" namespace mongo { diff --git a/src/mongo/db/query/interval.h b/src/mongo/db/query/interval.h index 2e8b52a6712..e86af179f78 100644 --- a/src/mongo/db/query/interval.h +++ b/src/mongo/db/query/interval.h @@ -30,7 +30,7 @@ #pragma once #include "mongo/db/jsobj.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" namespace mongo { @@ -53,7 +53,7 @@ struct Interval { Interval(); std::string toString() const { - mongoutils::str::stream ss; + str::stream ss; if (startInclusive) { ss << "["; } else { diff --git a/src/mongo/db/query/parsed_distinct.cpp b/src/mongo/db/query/parsed_distinct.cpp index 245392d95ad..b570b160a94 100644 --- a/src/mongo/db/query/parsed_distinct.cpp +++ b/src/mongo/db/query/parsed_distinct.cpp @@ -39,7 +39,7 @@ #include "mongo/db/repl/read_concern_args.h" #include "mongo/idl/idl_parser.h" #include "mongo/stdx/memory.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" namespace mongo { diff --git a/src/mongo/db/query/parsed_projection.cpp b/src/mongo/db/query/parsed_projection.cpp index 91b0156f8f4..415087e7fb1 100644 --- a/src/mongo/db/query/parsed_projection.cpp +++ b/src/mongo/db/query/parsed_projection.cpp @@ -114,7 +114,7 @@ Status ParsedProjection::make(OperationContext* opCtx, "Cannot specify positional operator and $elemMatch."); } - if (mongoutils::str::contains(elem.fieldName(), '.')) { + if (str::contains(elem.fieldName(), '.')) { return Status(ErrorCodes::BadValue, "Cannot use $elemMatch projection on a nested field."); } @@ -149,7 +149,7 @@ Status ParsedProjection::make(OperationContext* opCtx, pp->_arrayFields.push_back(elem.fieldNameStringData()); } else if (e2.fieldNameStringData() == "$meta") { // Field for meta must be top level. We can relax this at some point. - if (mongoutils::str::contains(elem.fieldName(), '.')) { + if (str::contains(elem.fieldName(), '.')) { return Status(ErrorCodes::BadValue, "field for $meta cannot be nested"); } @@ -231,17 +231,17 @@ Status ParsedProjection::make(OperationContext* opCtx, "Cannot specify positional operator and $elemMatch."); } - std::string after = mongoutils::str::after(elem.fieldName(), ".$"); - if (mongoutils::str::contains(after, ".$")) { - mongoutils::str::stream ss; + std::string after = str::after(elem.fieldName(), ".$"); + if (str::contains(after, ".$")) { + str::stream ss; ss << "Positional projection '" << elem.fieldName() << "' contains " << "the positional operator more than once."; return Status(ErrorCodes::BadValue, ss); } - std::string matchfield = mongoutils::str::before(elem.fieldName(), '.'); + std::string matchfield = str::before(elem.fieldName(), '.'); if (query && !_hasPositionalOperatorMatch(query, matchfield)) { - mongoutils::str::stream ss; + str::stream ss; ss << "Positional projection '" << elem.fieldName() << "' does not " << "match the query document."; return Status(ErrorCodes::BadValue, ss); @@ -382,10 +382,8 @@ bool ParsedProjection::isFieldRetainedExactly(StringData path) const { // static bool ParsedProjection::_isPositionalOperator(const char* fieldName) { - return mongoutils::str::contains(fieldName, ".$") && - !mongoutils::str::contains(fieldName, ".$ref") && - !mongoutils::str::contains(fieldName, ".$id") && - !mongoutils::str::contains(fieldName, ".$db"); + return str::contains(fieldName, ".$") && !str::contains(fieldName, ".$ref") && + !str::contains(fieldName, ".$id") && !str::contains(fieldName, ".$db"); } // static @@ -406,7 +404,7 @@ bool ParsedProjection::_hasPositionalOperatorMatch(const MatchExpression* const if (!pathRawData) { return false; } - std::string pathPrefix = mongoutils::str::before(pathRawData, '.'); + std::string pathPrefix = str::before(pathRawData, '.'); return pathPrefix == matchfield; } return false; diff --git a/src/mongo/db/query/parsed_projection.h b/src/mongo/db/query/parsed_projection.h index 4fbd6e21f35..e22a594a528 100644 --- a/src/mongo/db/query/parsed_projection.h +++ b/src/mongo/db/query/parsed_projection.h @@ -31,7 +31,7 @@ #include "mongo/db/jsobj.h" #include "mongo/db/matcher/expression_parser.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" namespace mongo { diff --git a/src/mongo/db/query/parsed_projection_test.cpp b/src/mongo/db/query/parsed_projection_test.cpp index 029f9b41fd4..84669166c8d 100644 --- a/src/mongo/db/query/parsed_projection_test.cpp +++ b/src/mongo/db/query/parsed_projection_test.cpp @@ -61,10 +61,9 @@ unique_ptr<ParsedProjection> createParsedProjection(const BSONObj& query, const ParsedProjection* out = NULL; Status status = ParsedProjection::make(opCtx.get(), projObj, queryMatchExpr.get(), &out); if (!status.isOK()) { - FAIL(mongoutils::str::stream() << "failed to parse projection " << projObj << " (query: " - << query - << "): " - << status.toString()); + FAIL(str::stream() << "failed to parse projection " << projObj << " (query: " << query + << "): " + << status.toString()); } ASSERT(out); return unique_ptr<ParsedProjection>(out); diff --git a/src/mongo/db/query/plan_enumerator.cpp b/src/mongo/db/query/plan_enumerator.cpp index 1dbdb6c973d..8bc87ce75cb 100644 --- a/src/mongo/db/query/plan_enumerator.cpp +++ b/src/mongo/db/query/plan_enumerator.cpp @@ -48,8 +48,8 @@ using std::string; using std::vector; std::string getPathPrefix(std::string path) { - if (mongoutils::str::contains(path, '.')) { - return mongoutils::str::before(path, '.'); + if (str::contains(path, '.')) { + return str::before(path, '.'); } else { return path; } @@ -282,7 +282,7 @@ Status PlanEnumerator::init() { } std::string PlanEnumerator::dumpMemo() { - mongoutils::str::stream ss; + str::stream ss; // Note that this needs to be kept in sync with allocateAssignment which assigns memo IDs. for (size_t i = 1; i <= _memo.size(); ++i) { @@ -293,7 +293,7 @@ std::string PlanEnumerator::dumpMemo() { string PlanEnumerator::NodeAssignment::toString() const { if (NULL != andAssignment) { - mongoutils::str::stream ss; + str::stream ss; ss << "AND enumstate counter " << andAssignment->counter; for (size_t i = 0; i < andAssignment->choices.size(); ++i) { ss << "\n\tchoice " << i << ":\n"; @@ -319,7 +319,7 @@ string PlanEnumerator::NodeAssignment::toString() const { } return ss; } else if (NULL != arrayAssignment) { - mongoutils::str::stream ss; + str::stream ss; ss << "ARRAY SUBNODES enumstate " << arrayAssignment->counter << "/ ONE OF: [ "; for (size_t i = 0; i < arrayAssignment->subnodes.size(); ++i) { ss << arrayAssignment->subnodes[i] << " "; @@ -328,7 +328,7 @@ string PlanEnumerator::NodeAssignment::toString() const { return ss; } else { verify(NULL != orAssignment); - mongoutils::str::stream ss; + str::stream ss; ss << "ALL OF: [ "; for (size_t i = 0; i < orAssignment->subnodes.size(); ++i) { ss << orAssignment->subnodes[i] << " "; diff --git a/src/mongo/db/query/plan_ranker.cpp b/src/mongo/db/query/plan_ranker.cpp index baf92677727..4d3069fb47a 100644 --- a/src/mongo/db/query/plan_ranker.cpp +++ b/src/mongo/db/query/plan_ranker.cpp @@ -242,7 +242,7 @@ double PlanRanker::scoreTree(const PlanStageStats* stats) { double tieBreakers = noFetchBonus + noSortBonus + noIxisectBonus; double score = baseScore + productivity + tieBreakers; - mongoutils::str::stream ss; + str::stream ss; ss << "score(" << score << ") = baseScore(" << baseScore << ")" << " + productivity((" << stats->common.advanced << " advanced)/(" << stats->common.works << " works) = " << productivity << ")" diff --git a/src/mongo/db/query/planner_ixselect_test.cpp b/src/mongo/db/query/planner_ixselect_test.cpp index 1f021e13d6e..e80eddd187b 100644 --- a/src/mongo/db/query/planner_ixselect_test.cpp +++ b/src/mongo/db/query/planner_ixselect_test.cpp @@ -70,7 +70,7 @@ unique_ptr<MatchExpression> parseMatchExpression(const BSONObj& obj) { */ template <typename Iter> string toString(Iter begin, Iter end) { - mongoutils::str::stream ss; + str::stream ss; ss << "["; for (Iter i = begin; i != end; i++) { if (i != begin) { @@ -100,7 +100,7 @@ void testGetFields(const char* query, const char* prefix, const char* expectedFi for (vector<string>::const_iterator i = expectedFields.begin(); i != expectedFields.end(); i++) { if (fields.find(*i) == fields.end()) { - mongoutils::str::stream ss; + str::stream ss; ss << "getFields(query=" << query << ", prefix=" << prefix << "): unable to find " << *i << " in result: " << toString(fields.begin(), fields.end()); FAIL(ss); @@ -109,7 +109,7 @@ void testGetFields(const char* query, const char* prefix, const char* expectedFi // Next, confirm that results do not contain any unexpected fields. if (fields.size() != expectedFields.size()) { - mongoutils::str::stream ss; + str::stream ss; ss << "getFields(query=" << query << ", prefix=" << prefix << "): unexpected fields in result. expected: " << toString(expectedFields.begin(), expectedFields.end()) @@ -173,7 +173,7 @@ void findRelevantTaggedNodePathsAndIndices(MatchExpression* root, tag->debugString(&buf); RelevantTag* r = dynamic_cast<RelevantTag*>(tag); if (!r) { - mongoutils::str::stream ss; + str::stream ss; ss << "tag is not instance of RelevantTag. tree: " << root->debugString() << "; tag: " << buf.str(); FAIL(ss); @@ -235,7 +235,7 @@ void testRateIndices(const char* query, // Compare the expected indices with the actual indices. if (actualIndices != expectedIndices) { - mongoutils::str::stream ss; + str::stream ss; ss << "rateIndices(query=" << query << ", prefix=" << prefix << "): expected indices did not match actual indices. expected: " << toString(expectedIndices.begin(), expectedIndices.end()) @@ -247,7 +247,7 @@ void testRateIndices(const char* query, // First verify number of paths retrieved. vector<string> expectedPaths = StringSplitter::split(expectedPathsStr, ","); if (paths.size() != expectedPaths.size()) { - mongoutils::str::stream ss; + str::stream ss; ss << "rateIndices(query=" << query << ", prefix=" << prefix << "): unexpected number of tagged nodes found. expected: " << toString(expectedPaths.begin(), expectedPaths.end()) @@ -262,7 +262,7 @@ void testRateIndices(const char* query, if (*i == *j) { continue; } - mongoutils::str::stream ss; + str::stream ss; ss << "rateIndices(query=" << query << ", prefix=" << prefix << "): unexpected path found. expected: " << *j << " " << toString(expectedPaths.begin(), expectedPaths.end()) << ". actual: " << *i << " " diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp index d7503c724a8..fb819ce9c36 100644 --- a/src/mongo/db/query/query_planner.cpp +++ b/src/mongo/db/query/query_planner.cpp @@ -87,7 +87,7 @@ static bool is2DIndex(const BSONObj& pattern) { } string optionString(size_t options) { - mongoutils::str::stream ss; + str::stream ss; if (QueryPlannerParams::DEFAULT == options) { ss << "DEFAULT "; @@ -308,7 +308,7 @@ StatusWith<std::unique_ptr<PlanCacheIndexTree>> QueryPlanner::cacheDataFromTagge taggedTree->getTag()->getType() == MatchExpression::TagData::Type::IndexTag) { IndexTag* itag = static_cast<IndexTag*>(taggedTree->getTag()); if (itag->index >= relevantIndices.size()) { - mongoutils::str::stream ss; + str::stream ss; ss << "Index number is " << itag->index << " but there are only " << relevantIndices.size() << " relevant indices."; return Status(ErrorCodes::BadValue, ss); @@ -384,7 +384,7 @@ Status QueryPlanner::tagAccordingToCache(MatchExpression* filter, verify(NULL == filter->getTag()); if (filter->numChildren() != indexTree->children.size()) { - mongoutils::str::stream ss; + str::stream ss; ss << "Cache topology and query did not match: " << "query has " << filter->numChildren() << " children " << "and cache has " << indexTree->children.size() << " children."; @@ -419,7 +419,7 @@ Status QueryPlanner::tagAccordingToCache(MatchExpression* filter, if (indexTree->entry.get()) { const auto got = indexMap.find(indexTree->entry->identifier); if (got == indexMap.end()) { - mongoutils::str::stream ss; + str::stream ss; ss << "Did not find index with name: " << indexTree->entry->identifier.catalogName; return Status(ErrorCodes::BadValue, ss); } diff --git a/src/mongo/db/query/query_planner_test_fixture.cpp b/src/mongo/db/query/query_planner_test_fixture.cpp index d04d3060b4a..59306ff1feb 100644 --- a/src/mongo/db/query/query_planner_test_fixture.cpp +++ b/src/mongo/db/query/query_planner_test_fixture.cpp @@ -473,12 +473,12 @@ size_t QueryPlannerTest::getNumSolutions() const { } void QueryPlannerTest::dumpSolutions() const { - mongoutils::str::stream ost; + str::stream ost; dumpSolutions(ost); log() << std::string(ost); } -void QueryPlannerTest::dumpSolutions(mongoutils::str::stream& ost) const { +void QueryPlannerTest::dumpSolutions(str::stream& ost) const { for (auto&& soln : solns) { ost << soln->toString() << '\n'; } @@ -488,7 +488,7 @@ void QueryPlannerTest::assertNumSolutions(size_t expectSolutions) const { if (getNumSolutions() == expectSolutions) { return; } - mongoutils::str::stream ss; + str::stream ss; ss << "expected " << expectSolutions << " solutions but got " << getNumSolutions() << " instead. solutions generated: " << '\n'; dumpSolutions(ss); @@ -512,7 +512,7 @@ void QueryPlannerTest::assertSolutionExists(const std::string& solnJson, size_t if (numMatches == matches) { return; } - mongoutils::str::stream ss; + str::stream ss; ss << "expected " << numMatches << " matches for solution " << solnJson << " but got " << matches << " instead. all solutions generated: " << '\n'; dumpSolutions(ss); @@ -530,7 +530,7 @@ void QueryPlannerTest::assertHasOneSolutionOf(const std::vector<std::string>& so if (1U == matches) { return; } - mongoutils::str::stream ss; + str::stream ss; ss << "assertHasOneSolutionOf expected one matching solution" << " but got " << matches << " instead. all solutions generated: " << '\n'; dumpSolutions(ss); diff --git a/src/mongo/db/query/query_planner_test_fixture.h b/src/mongo/db/query/query_planner_test_fixture.h index 885401b6900..b314099057f 100644 --- a/src/mongo/db/query/query_planner_test_fixture.h +++ b/src/mongo/db/query/query_planner_test_fixture.h @@ -174,7 +174,7 @@ protected: void dumpSolutions() const; - void dumpSolutions(mongoutils::str::stream& ost) const; + void dumpSolutions(str::stream& ost) const; /** * Will use a relaxed bounds check for the remaining assert* calls. Subsequent calls to assert* diff --git a/src/mongo/db/query/query_request.cpp b/src/mongo/db/query/query_request.cpp index 6cdca0a5327..ca26724a64b 100644 --- a/src/mongo/db/query/query_request.cpp +++ b/src/mongo/db/query/query_request.cpp @@ -42,7 +42,7 @@ #include "mongo/db/repl/read_concern_args.h" #include "mongo/stdx/memory.h" #include "mongo/util/assert_util.h" -#include "mongo/util/mongoutils/str.h" +#include "mongo/util/str.h" namespace mongo { diff --git a/src/mongo/db/query/query_solution.cpp b/src/mongo/db/query/query_solution.cpp index dd0be890782..23c83c6fb8a 100644 --- a/src/mongo/db/query/query_solution.cpp +++ b/src/mongo/db/query/query_solution.cpp @@ -157,19 +157,19 @@ void addEqualityFieldSorts(const BSONObj& sortPattern, } string QuerySolutionNode::toString() const { - mongoutils::str::stream ss; + str::stream ss; appendToString(&ss, 0); return ss; } // static -void QuerySolutionNode::addIndent(mongoutils::str::stream* ss, int level) { +void QuerySolutionNode::addIndent(str::stream* ss, int level) { for (int i = 0; i < level; ++i) { *ss << "---"; } } -void QuerySolutionNode::addCommon(mongoutils::str::stream* ss, int indent) const { +void QuerySolutionNode::addCommon(str::stream* ss, int indent) const { addIndent(ss, indent + 1); *ss << "fetched = " << fetched() << '\n'; addIndent(ss, indent + 1); @@ -186,7 +186,7 @@ void QuerySolutionNode::addCommon(mongoutils::str::stream* ss, int indent) const // TextNode // -void TextNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void TextNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "TEXT\n"; addIndent(ss, indent + 1); @@ -228,7 +228,7 @@ QuerySolutionNode* TextNode::clone() const { CollectionScanNode::CollectionScanNode() : _sort(SimpleBSONObjComparator::kInstance.makeBSONObjSet()), tailable(false), direction(1) {} -void CollectionScanNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void CollectionScanNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "COLLSCAN\n"; addIndent(ss, indent + 1); @@ -262,7 +262,7 @@ AndHashNode::AndHashNode() : _sort(SimpleBSONObjComparator::kInstance.makeBSONOb AndHashNode::~AndHashNode() {} -void AndHashNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void AndHashNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "AND_HASH\n"; if (NULL != filter) { @@ -316,7 +316,7 @@ AndSortedNode::AndSortedNode() : _sort(SimpleBSONObjComparator::kInstance.makeBS AndSortedNode::~AndSortedNode() {} -void AndSortedNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void AndSortedNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "AND_SORTED\n"; addCommon(ss, indent); @@ -366,7 +366,7 @@ OrNode::OrNode() : _sort(SimpleBSONObjComparator::kInstance.makeBSONObjSet()), d OrNode::~OrNode() {} -void OrNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void OrNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "OR\n"; if (NULL != filter) { @@ -427,7 +427,7 @@ MergeSortNode::MergeSortNode() MergeSortNode::~MergeSortNode() {} -void MergeSortNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void MergeSortNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "MERGE_SORT\n"; if (NULL != filter) { @@ -486,7 +486,7 @@ QuerySolutionNode* MergeSortNode::clone() const { FetchNode::FetchNode() : _sorts(SimpleBSONObjComparator::kInstance.makeBSONObjSet()) {} -void FetchNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void FetchNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "FETCH\n"; if (NULL != filter) { @@ -523,7 +523,7 @@ IndexScanNode::IndexScanNode(IndexEntry index) shouldDedup(index.multikey), queryCollator(nullptr) {} -void IndexScanNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void IndexScanNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "IXSCAN\n"; addIndent(ss, indent + 1); @@ -851,7 +851,7 @@ bool IndexScanNode::operator==(const IndexScanNode& other) const { // ProjectionNode // -void ProjectionNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void ProjectionNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "PROJ\n"; addIndent(ss, indent + 1); @@ -932,7 +932,7 @@ ProjectionNode* ProjectionNodeSimple::clone() const { // SortKeyGeneratorNode // -void SortKeyGeneratorNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void SortKeyGeneratorNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "SORT_KEY_GENERATOR\n"; addIndent(ss, indent + 1); @@ -954,7 +954,7 @@ QuerySolutionNode* SortKeyGeneratorNode::clone() const { // SortNode // -void SortNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void SortNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "SORT\n"; addIndent(ss, indent + 1); @@ -983,7 +983,7 @@ QuerySolutionNode* SortNode::clone() const { // -void LimitNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void LimitNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "LIMIT\n"; addIndent(ss, indent + 1); @@ -1008,7 +1008,7 @@ QuerySolutionNode* LimitNode::clone() const { // SkipNode // -void SkipNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void SkipNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "SKIP\n"; addIndent(ss, indent + 1); @@ -1032,7 +1032,7 @@ QuerySolutionNode* SkipNode::clone() const { // GeoNear2DNode // -void GeoNear2DNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void GeoNear2DNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "GEO_NEAR_2D\n"; addIndent(ss, indent + 1); @@ -1064,7 +1064,7 @@ QuerySolutionNode* GeoNear2DNode::clone() const { // GeoNear2DSphereNode // -void GeoNear2DSphereNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void GeoNear2DSphereNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "GEO_NEAR_2DSPHERE\n"; addIndent(ss, indent + 1); @@ -1098,7 +1098,7 @@ QuerySolutionNode* GeoNear2DSphereNode::clone() const { // ShardingFilterNode // -void ShardingFilterNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void ShardingFilterNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "SHARDING_FILTER\n"; if (NULL != filter) { @@ -1124,7 +1124,7 @@ QuerySolutionNode* ShardingFilterNode::clone() const { // DistinctNode // -void DistinctNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void DistinctNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "DISTINCT\n"; addIndent(ss, indent + 1); @@ -1162,7 +1162,7 @@ void DistinctNode::computeProperties() { // CountScanNode // -void CountScanNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void CountScanNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "COUNT\n"; addIndent(ss, indent + 1); @@ -1192,7 +1192,7 @@ QuerySolutionNode* CountScanNode::clone() const { // EnsureSortedNode // -void EnsureSortedNode::appendToString(mongoutils::str::stream* ss, int indent) const { +void EnsureSortedNode::appendToString(str::stream* ss, int indent) const { addIndent(ss, indent); *ss << "ENSURE_SORTED\n"; addIndent(ss, indent + 1); diff --git a/src/mongo/db/query/query_solution.h b/src/mongo/db/query/query_solution.h index 04e6cd6d997..44c63d4bfb6 100644 --- a/src/mongo/db/query/query_solution.h +++ b/src/mongo/db/query/query_solution.h @@ -77,7 +77,7 @@ struct QuerySolutionNode { * * TODO: Consider outputting into a BSONObj or builder thereof. */ - virtual void appendToString(mongoutils::str::stream* ss, int indent) const = 0; + virtual void appendToString(str::stream* ss, int indent) const = 0; // // Computed properties @@ -179,13 +179,13 @@ protected: /** * Formatting helper used by toString(). */ - static void addIndent(mongoutils::str::stream* ss, int level); + static void addIndent(str::stream* ss, int level); /** * Every solution node has properties and this adds the debug info for the * properties. */ - void addCommon(mongoutils::str::stream* ss, int indent) const; + void addCommon(str::stream* ss, int indent) const; private: QuerySolutionNode(const QuerySolutionNode&) = delete; @@ -233,7 +233,7 @@ struct QuerySolution { return "empty query solution"; } - mongoutils::str::stream ss; + str::stream ss; root->appendToString(&ss, 0); return ss; } @@ -253,7 +253,7 @@ struct TextNode : public QuerySolutionNode { return STAGE_TEXT; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; // Text's return is LOC_AND_OBJ so it's fetched and has all fields. bool fetched() const { @@ -297,7 +297,7 @@ struct CollectionScanNode : public QuerySolutionNode { return STAGE_COLLSCAN; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const { return true; @@ -341,7 +341,7 @@ struct AndHashNode : public QuerySolutionNode { return STAGE_AND_HASH; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const; bool hasField(const std::string& field) const; @@ -365,7 +365,7 @@ struct AndSortedNode : public QuerySolutionNode { return STAGE_AND_SORTED; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const; bool hasField(const std::string& field) const; @@ -389,7 +389,7 @@ struct OrNode : public QuerySolutionNode { return STAGE_OR; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const; bool hasField(const std::string& field) const; @@ -417,7 +417,7 @@ struct MergeSortNode : public QuerySolutionNode { return STAGE_SORT_MERGE; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const; bool hasField(const std::string& field) const; @@ -453,7 +453,7 @@ struct FetchNode : public QuerySolutionNode { return STAGE_FETCH; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const { return true; @@ -483,7 +483,7 @@ struct IndexScanNode : public QuerySolutionNode { return STAGE_IXSCAN; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const { return false; @@ -547,7 +547,7 @@ struct ProjectionNode : QuerySolutionNode { void computeProperties() final; - void appendToString(mongoutils::str::stream* ss, int indent) const final; + void appendToString(str::stream* ss, int indent) const final; /** * Data from the projection node is considered fetch iff the child provides fetched data. @@ -684,7 +684,7 @@ struct SortKeyGeneratorNode : public QuerySolutionNode { QuerySolutionNode* clone() const final; - void appendToString(mongoutils::str::stream* ss, int indent) const final; + void appendToString(str::stream* ss, int indent) const final; // The user-supplied sort pattern. BSONObj sortSpec; @@ -699,7 +699,7 @@ struct SortNode : public QuerySolutionNode { return STAGE_SORT; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const { return children[0]->fetched(); @@ -741,7 +741,7 @@ struct LimitNode : public QuerySolutionNode { return STAGE_LIMIT; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const { return children[0]->fetched(); @@ -768,7 +768,7 @@ struct SkipNode : public QuerySolutionNode { virtual StageType getType() const { return STAGE_SKIP; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const { return children[0]->fetched(); @@ -801,7 +801,7 @@ struct GeoNear2DNode : public QuerySolutionNode { virtual StageType getType() const { return STAGE_GEO_NEAR_2D; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const { return true; @@ -842,7 +842,7 @@ struct GeoNear2DSphereNode : public QuerySolutionNode { virtual StageType getType() const { return STAGE_GEO_NEAR_2DSPHERE; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const { return true; @@ -887,7 +887,7 @@ struct ShardingFilterNode : public QuerySolutionNode { virtual StageType getType() const { return STAGE_SHARDING_FILTER; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const { return children[0]->fetched(); @@ -918,7 +918,7 @@ struct DistinctNode : public QuerySolutionNode { virtual StageType getType() const { return STAGE_DISTINCT_SCAN; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; // This stage is created "on top" of normal planning and as such the properties // below don't really matter. @@ -964,7 +964,7 @@ struct CountScanNode : public QuerySolutionNode { virtual StageType getType() const { return STAGE_COUNT_SCAN; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const { return false; @@ -1003,7 +1003,7 @@ struct EnsureSortedNode : public QuerySolutionNode { return STAGE_ENSURE_SORTED; } - virtual void appendToString(mongoutils::str::stream* ss, int indent) const; + virtual void appendToString(str::stream* ss, int indent) const; bool fetched() const { return children[0]->fetched(); diff --git a/src/mongo/db/query/query_solution_test.cpp b/src/mongo/db/query/query_solution_test.cpp index 1fcfe1c8bd8..7ac47cb2aad 100644 --- a/src/mongo/db/query/query_solution_test.cpp +++ b/src/mongo/db/query/query_solution_test.cpp @@ -726,10 +726,9 @@ auto createMatchExprAndParsedProjection(const BSONObj& query, const BSONObj& pro Status status = ParsedProjection::make(opCtx.get(), projObj, queryMatchExpr.getValue().get(), &out); if (!status.isOK()) { - FAIL(mongoutils::str::stream() << "failed to parse projection " << projObj << " (query: " - << query - << "): " - << status.toString()); + FAIL(str::stream() << "failed to parse projection " << projObj << " (query: " << query + << "): " + << status.toString()); } ASSERT(out); return std::make_pair(std::move(queryMatchExpr.getValue()), diff --git a/src/mongo/db/query/stage_builder.cpp b/src/mongo/db/query/stage_builder.cpp index 24b74ad206d..012efb8a262 100644 --- a/src/mongo/db/query/stage_builder.cpp +++ b/src/mongo/db/query/stage_builder.cpp @@ -389,7 +389,7 @@ PlanStage* buildStages(OperationContext* opCtx, case STAGE_TRIAL: case STAGE_UNKNOWN: case STAGE_UPDATE: { - mongoutils::str::stream ss; + str::stream ss; root->appendToString(&ss, 0); string nodeStr(ss); warning() << "Can't build exec tree for node " << nodeStr << endl; |