summaryrefslogtreecommitdiff
path: root/src/mongo/db/fts
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2016-05-28 17:55:12 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2016-05-28 17:55:12 -0400
commit6dcdd23dd37ef12c87e71cf59ef01cd82432efe0 (patch)
treec8cfb5acb62c80f375bc37e7d4350382deea6a37 /src/mongo/db/fts
parentd4ac5673ea3f6cef4ce9dbcec90e31813997a528 (diff)
downloadmongo-6dcdd23dd37ef12c87e71cf59ef01cd82432efe0.tar.gz
SERVER-23971 Clang-Format code
Diffstat (limited to 'src/mongo/db/fts')
-rw-r--r--src/mongo/db/fts/fts_element_iterator.cpp3
-rw-r--r--src/mongo/db/fts/fts_index_format.cpp7
-rw-r--r--src/mongo/db/fts/fts_index_format_test.cpp32
-rw-r--r--src/mongo/db/fts/fts_language.cpp9
-rw-r--r--src/mongo/db/fts/fts_language.h2
-rw-r--r--src/mongo/db/fts/fts_language_test.cpp2
-rw-r--r--src/mongo/db/fts/fts_matcher.cpp2
-rw-r--r--src/mongo/db/fts/fts_query_impl.cpp4
-rw-r--r--src/mongo/db/fts/fts_query_impl_test.cpp25
-rw-r--r--src/mongo/db/fts/fts_spec.cpp14
-rw-r--r--src/mongo/db/fts/fts_spec.h2
-rw-r--r--src/mongo/db/fts/fts_spec_legacy.cpp4
-rw-r--r--src/mongo/db/fts/fts_spec_test.cpp22
13 files changed, 76 insertions, 52 deletions
diff --git a/src/mongo/db/fts/fts_element_iterator.cpp b/src/mongo/db/fts/fts_element_iterator.cpp
index 4df642dc66a..0e2d0b8d463 100644
--- a/src/mongo/db/fts/fts_element_iterator.cpp
+++ b/src/mongo/db/fts/fts_element_iterator.cpp
@@ -47,7 +47,8 @@ extern const double MAX_WEIGHT;
std::ostream& operator<<(std::ostream& os, FTSElementIterator::FTSIteratorFrame& frame) {
BSONObjIterator it = frame._it;
return os << "FTSIteratorFrame["
- " element=" << (*it).toString() << ", _language=" << frame._language->str()
+ " element="
+ << (*it).toString() << ", _language=" << frame._language->str()
<< ", _parentPath=" << frame._parentPath << ", _isArray=" << frame._isArray << "]";
}
diff --git a/src/mongo/db/fts/fts_index_format.cpp b/src/mongo/db/fts/fts_index_format.cpp
index 30814b54d78..c9698d59c93 100644
--- a/src/mongo/db/fts/fts_index_format.cpp
+++ b/src/mongo/db/fts/fts_index_format.cpp
@@ -139,7 +139,8 @@ void FTSIndexFormat::getKeys(const FTSSpec& spec, const BSONObj& obj, BSONObjSet
uassert(16732,
mongoutils::str::stream() << "too many unique keys for a single document to"
- << " have a text index, max is " << term_freqs.size()
+ << " have a text index, max is "
+ << term_freqs.size()
<< obj["_id"],
term_freqs.size() <= 400000);
@@ -173,7 +174,9 @@ void FTSIndexFormat::getKeys(const FTSSpec& spec, const BSONObj& obj, BSONObjSet
uassert(16733,
mongoutils::str::stream()
<< "trying to index text where term list is too big, max is "
- << MaxKeyBSONSizeMB << "mb " << obj["_id"],
+ << MaxKeyBSONSizeMB
+ << "mb "
+ << obj["_id"],
keyBSONSize <= (MaxKeyBSONSizeMB * 1024 * 1024));
}
}
diff --git a/src/mongo/db/fts/fts_index_format_test.cpp b/src/mongo/db/fts/fts_index_format_test.cpp
index af353d51f26..03eb7406a79 100644
--- a/src/mongo/db/fts/fts_index_format_test.cpp
+++ b/src/mongo/db/fts/fts_index_format_test.cpp
@@ -36,9 +36,9 @@
#include "mongo/db/fts/fts_index_format.h"
#include "mongo/db/fts/fts_spec.h"
+#include "mongo/unittest/unittest.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
-#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -67,12 +67,14 @@ TEST(FTSIndexFormat, Simple1) {
TEST(FTSIndexFormat, ExtraBack1) {
FTSSpec spec(assertGet(FTSSpec::fixSpec(BSON("key" << BSON("data"
<< "text"
- << "x" << 1)))));
+ << "x"
+ << 1)))));
BSONObjSet keys;
FTSIndexFormat::getKeys(spec,
BSON("data"
<< "cat"
- << "x" << 5),
+ << "x"
+ << 5),
&keys);
ASSERT_EQUALS(1U, keys.size());
@@ -91,7 +93,8 @@ TEST(FTSIndexFormat, ExtraFront1) {
FTSIndexFormat::getKeys(spec,
BSON("data"
<< "cat"
- << "x" << 5),
+ << "x"
+ << 5),
&keys);
ASSERT_EQUALS(1U, keys.size());
@@ -152,9 +155,10 @@ void assertEqualsIndexKeys(std::set<std::string>& expectedKeys, const BSONObjSet
* Terms that are too long are not truncated in version 1.
*/
TEST(FTSIndexFormat, LongWordsTextIndexVersion1) {
- FTSSpec spec(
- assertGet(FTSSpec::fixSpec(BSON("key" << BSON("data"
- << "text") << "textIndexVersion" << 1))));
+ FTSSpec spec(assertGet(FTSSpec::fixSpec(BSON("key" << BSON("data"
+ << "text")
+ << "textIndexVersion"
+ << 1))));
BSONObjSet keys;
string longPrefix(1024U, 'a');
// "aaa...aaacat"
@@ -181,9 +185,10 @@ TEST(FTSIndexFormat, LongWordsTextIndexVersion1) {
* characters of the term to form the index key.
*/
TEST(FTSIndexFormat, LongWordTextIndexVersion2) {
- FTSSpec spec(
- assertGet(FTSSpec::fixSpec(BSON("key" << BSON("data"
- << "text") << "textIndexVersion" << 2))));
+ FTSSpec spec(assertGet(FTSSpec::fixSpec(BSON("key" << BSON("data"
+ << "text")
+ << "textIndexVersion"
+ << 2))));
BSONObjSet keys;
string longPrefix(1024U, 'a');
// "aaa...aaacat"
@@ -215,9 +220,10 @@ TEST(FTSIndexFormat, LongWordTextIndexVersion2) {
* characters of the term to form the index key.
*/
TEST(FTSIndexFormat, LongWordTextIndexVersion3) {
- FTSSpec spec(
- assertGet(FTSSpec::fixSpec(BSON("key" << BSON("data"
- << "text") << "textIndexVersion" << 3))));
+ FTSSpec spec(assertGet(FTSSpec::fixSpec(BSON("key" << BSON("data"
+ << "text")
+ << "textIndexVersion"
+ << 3))));
BSONObjSet keys;
string longPrefix(1024U, 'a');
// "aaa...aaacat"
diff --git a/src/mongo/db/fts/fts_language.cpp b/src/mongo/db/fts/fts_language.cpp
index b01e9de6508..f52002b9be0 100644
--- a/src/mongo/db/fts/fts_language.cpp
+++ b/src/mongo/db/fts/fts_language.cpp
@@ -279,10 +279,11 @@ StatusWithFTSLanguage FTSLanguage::make(StringData langName, TextIndexVersion te
if (it == languageMap->end()) {
// TEXT_INDEX_VERSION_2 and above reject unrecognized language strings.
- Status status = Status(ErrorCodes::BadValue,
- mongoutils::str::stream()
- << "unsupported language: \"" << langName
- << "\" for text index version " << textIndexVersion);
+ Status status =
+ Status(ErrorCodes::BadValue,
+ mongoutils::str::stream() << "unsupported language: \"" << langName
+ << "\" for text index version "
+ << textIndexVersion);
return StatusWithFTSLanguage(status);
}
diff --git a/src/mongo/db/fts/fts_language.h b/src/mongo/db/fts/fts_language.h
index 062a3255ba1..49da2439529 100644
--- a/src/mongo/db/fts/fts_language.h
+++ b/src/mongo/db/fts/fts_language.h
@@ -30,11 +30,11 @@
#pragma once
+#include "mongo/base/status_with.h"
#include "mongo/db/fts/fts_basic_phrase_matcher.h"
#include "mongo/db/fts/fts_phrase_matcher.h"
#include "mongo/db/fts/fts_unicode_phrase_matcher.h"
#include "mongo/db/fts/fts_util.h"
-#include "mongo/base/status_with.h"
#include <string>
diff --git a/src/mongo/db/fts/fts_language_test.cpp b/src/mongo/db/fts/fts_language_test.cpp
index 87e37272850..3049d8d4af8 100644
--- a/src/mongo/db/fts/fts_language_test.cpp
+++ b/src/mongo/db/fts/fts_language_test.cpp
@@ -28,9 +28,9 @@
* it in the license file.
*/
-#include "mongo/platform/basic.h"
#include "mongo/db/fts/fts_language.h"
#include "mongo/db/fts/fts_spec.h"
+#include "mongo/platform/basic.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
diff --git a/src/mongo/db/fts/fts_matcher.cpp b/src/mongo/db/fts/fts_matcher.cpp
index 6a782e730cc..b3107418542 100644
--- a/src/mongo/db/fts/fts_matcher.cpp
+++ b/src/mongo/db/fts/fts_matcher.cpp
@@ -30,10 +30,10 @@
#include "mongo/platform/basic.h"
+#include "mongo/db/fts/fts_element_iterator.h"
#include "mongo/db/fts/fts_matcher.h"
#include "mongo/db/fts/fts_phrase_matcher.h"
#include "mongo/db/fts/fts_tokenizer.h"
-#include "mongo/db/fts/fts_element_iterator.h"
namespace mongo {
diff --git a/src/mongo/db/fts/fts_query_impl.cpp b/src/mongo/db/fts/fts_query_impl.cpp
index bc879375e88..040333de5c7 100644
--- a/src/mongo/db/fts/fts_query_impl.cpp
+++ b/src/mongo/db/fts/fts_query_impl.cpp
@@ -32,12 +32,12 @@
#include "mongo/db/fts/fts_query_impl.h"
-#include "mongo/db/fts/fts_spec.h"
#include "mongo/db/fts/fts_query_parser.h"
+#include "mongo/db/fts/fts_spec.h"
#include "mongo/db/fts/fts_tokenizer.h"
+#include "mongo/stdx/memory.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/stringutils.h"
-#include "mongo/stdx/memory.h"
namespace mongo {
diff --git a/src/mongo/db/fts/fts_query_impl_test.cpp b/src/mongo/db/fts/fts_query_impl_test.cpp
index 25f0f0fd211..43585e8a982 100644
--- a/src/mongo/db/fts/fts_query_impl_test.cpp
+++ b/src/mongo/db/fts/fts_query_impl_test.cpp
@@ -159,9 +159,8 @@ TEST(FTSQueryImpl, Phrase1) {
ASSERT(q.parse(TEXT_INDEX_VERSION_3).isOK());
ASSERT_EQUALS(q.toBSON(),
- fromjson(
- "{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase "
- "test'], negatedPhrases: []}"));
+ fromjson("{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase "
+ "test'], negatedPhrases: []}"));
ASSERT_TRUE(q.getTermsForBounds() == q.getPositiveTerms());
}
@@ -197,9 +196,8 @@ TEST(FTSQueryImpl, HyphenSurroundedByWhitespaceBeforePhraseShouldNotNegateEntire
q.setDiacriticSensitive(false);
ASSERT(q.parse(TEXT_INDEX_VERSION_3).isOK());
ASSERT_EQUALS(q.toBSON(),
- fromjson(
- "{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase "
- "test'], negatedPhrases: []}"));
+ fromjson("{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase "
+ "test'], negatedPhrases: []}"));
}
TEST(FTSQueryImpl, HyphenBetweenTermAndPhraseShouldBeTreatedAsDelimiter) {
@@ -210,9 +208,8 @@ TEST(FTSQueryImpl, HyphenBetweenTermAndPhraseShouldBeTreatedAsDelimiter) {
q.setDiacriticSensitive(false);
ASSERT(q.parse(TEXT_INDEX_VERSION_3).isOK());
ASSERT_EQUALS(q.toBSON(),
- fromjson(
- "{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase "
- "test'], negatedPhrases: []}"));
+ fromjson("{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase "
+ "test'], negatedPhrases: []}"));
}
TEST(FTSQueryImpl, HyphenShouldNegateAllSucceedingPhrasesSeparatedByHyphens) {
@@ -223,9 +220,8 @@ TEST(FTSQueryImpl, HyphenShouldNegateAllSucceedingPhrasesSeparatedByHyphens) {
q.setDiacriticSensitive(false);
ASSERT(q.parse(TEXT_INDEX_VERSION_3).isOK());
ASSERT_EQUALS(q.toBSON(),
- fromjson(
- "{terms: ['anoth', 'phrase'], negatedTerms: [], phrases: ['another "
- "phrase'], negatedPhrases: ['really fun', 'stuff here']}"));
+ fromjson("{terms: ['anoth', 'phrase'], negatedTerms: [], phrases: ['another "
+ "phrase'], negatedPhrases: ['really fun', 'stuff here']}"));
}
TEST(FTSQueryImpl, CaseSensitiveOption) {
@@ -309,9 +305,8 @@ TEST(FTSQueryImpl, Mix1) {
q.setDiacriticSensitive(false);
ASSERT(q.parse(TEXT_INDEX_VERSION_3).isOK());
ASSERT_EQUALS(q.toBSON(),
- fromjson(
- "{terms: ['industri'], negatedTerms: ['melbourn', 'physic'], phrases: "
- "['industry'], negatedPhrases: []}"));
+ fromjson("{terms: ['industri'], negatedTerms: ['melbourn', 'physic'], phrases: "
+ "['industry'], negatedPhrases: []}"));
}
TEST(FTSQueryImpl, NegPhrase2) {
diff --git a/src/mongo/db/fts/fts_spec.cpp b/src/mongo/db/fts/fts_spec.cpp
index 05248d157b7..0c03ed8aa18 100644
--- a/src/mongo/db/fts/fts_spec.cpp
+++ b/src/mongo/db/fts/fts_spec.cpp
@@ -58,7 +58,7 @@ const std::string moduleDefaultLanguage("english");
bool validateOverride(const string& override) {
// The override field can't be empty, can't be prefixed with a dollar sign, and
// can't contain a dot.
- return !override.empty() && override[0] != '$' && override.find('.') == std::string::npos;
+ return !override.empty()&& override[0] != '$' && override.find('.') == std::string::npos;
}
}
@@ -90,8 +90,12 @@ FTSSpec::FTSSpec(const BSONObj& indexInfo) {
msgasserted(17364,
str::stream() << "attempt to use unsupported textIndexVersion "
<< textIndexVersionElt.numberInt()
- << "; versions supported: " << TEXT_INDEX_VERSION_3 << ", "
- << TEXT_INDEX_VERSION_2 << ", " << TEXT_INDEX_VERSION_1);
+ << "; versions supported: "
+ << TEXT_INDEX_VERSION_3
+ << ", "
+ << TEXT_INDEX_VERSION_2
+ << ", "
+ << TEXT_INDEX_VERSION_1);
}
// Initialize _defaultLanguage. Note that the FTSLanguage constructor requires
@@ -401,7 +405,9 @@ StatusWith<BSONObj> FTSSpec::fixSpec(const BSONObj& spec) {
if (i->second <= 0 || i->second >= MAX_WORD_WEIGHT) {
return {ErrorCodes::CannotCreateIndex,
str::stream() << "text index weight must be in the exclusive interval (0,"
- << MAX_WORD_WEIGHT << ") but found: " << i->second};
+ << MAX_WORD_WEIGHT
+ << ") but found: "
+ << i->second};
}
// Verify weight refers to a valid field.
diff --git a/src/mongo/db/fts/fts_spec.h b/src/mongo/db/fts/fts_spec.h
index a00e04f7052..8cd293e70cf 100644
--- a/src/mongo/db/fts/fts_spec.h
+++ b/src/mongo/db/fts/fts_spec.h
@@ -31,8 +31,8 @@
#pragma once
#include <map>
-#include <vector>
#include <string>
+#include <vector>
#include "mongo/base/status_with.h"
#include "mongo/db/fts/fts_language.h"
diff --git a/src/mongo/db/fts/fts_spec_legacy.cpp b/src/mongo/db/fts/fts_spec_legacy.cpp
index 15739d8787d..f660c00f526 100644
--- a/src/mongo/db/fts/fts_spec_legacy.cpp
+++ b/src/mongo/db/fts/fts_spec_legacy.cpp
@@ -241,7 +241,9 @@ StatusWith<BSONObj> FTSSpec::_fixSpecV1(const BSONObj& spec) {
if (i->second <= 0 || i->second >= MAX_WORD_WEIGHT) {
return {ErrorCodes::CannotCreateIndex,
str::stream() << "text index weight must be in the exclusive interval (0,"
- << MAX_WORD_WEIGHT << ") but found: " << i->second};
+ << MAX_WORD_WEIGHT
+ << ") but found: "
+ << i->second};
}
b.append(i->first, i->second);
}
diff --git a/src/mongo/db/fts/fts_spec_test.cpp b/src/mongo/db/fts/fts_spec_test.cpp
index 5ecc0109333..3c041cbd363 100644
--- a/src/mongo/db/fts/fts_spec_test.cpp
+++ b/src/mongo/db/fts/fts_spec_test.cpp
@@ -184,7 +184,9 @@ TEST(FTSSpec, ScoreSingleField1) {
BSONObj user = BSON("key" << BSON("title"
<< "text"
<< "text"
- << "text") << "weights" << BSON("title" << 10));
+ << "text")
+ << "weights"
+ << BSON("title" << 10));
FTSSpec spec(assertGet(FTSSpec::fixSpec(user)));
@@ -202,7 +204,9 @@ TEST(FTSSpec, ScoreMultipleField1) {
BSONObj user = BSON("key" << BSON("title"
<< "text"
<< "text"
- << "text") << "weights" << BSON("title" << 10));
+ << "text")
+ << "weights"
+ << BSON("title" << 10));
FTSSpec spec(assertGet(FTSSpec::fixSpec(user)));
@@ -243,7 +247,9 @@ TEST(FTSSpec, ScoreRepeatWord) {
BSONObj user = BSON("key" << BSON("title"
<< "text"
<< "text"
- << "text") << "weights" << BSON("title" << 10));
+ << "text")
+ << "weights"
+ << BSON("title" << 10));
FTSSpec spec(assertGet(FTSSpec::fixSpec(user)));
@@ -268,7 +274,8 @@ TEST(FTSSpec, Extra1) {
TEST(FTSSpec, Extra2) {
BSONObj user = BSON("key" << BSON("data"
<< "text"
- << "x" << 1));
+ << "x"
+ << 1));
BSONObj fixed = assertGet(FTSSpec::fixSpec(user));
FTSSpec spec(fixed);
ASSERT_EQUALS(0U, spec.numExtraBefore());
@@ -286,7 +293,8 @@ TEST(FTSSpec, Extra3) {
ASSERT_EQUALS(BSON("x" << 1 << "_fts"
<< "text"
- << "_ftsx" << 1),
+ << "_ftsx"
+ << 1),
fixed["key"].Obj());
ASSERT_EQUALS(BSON("data" << 1), fixed["weights"].Obj());
@@ -512,7 +520,9 @@ TEST(FTSSpec, NestedLanguages_Wildcard) {
// Multi-language test_6: test wildcard spec with override
TEST(FTSSpec, NestedLanguages_WildcardOverride) {
BSONObj indexSpec = BSON("key" << BSON("$**"
- << "text") << "weights" << BSON("d.e.f" << 20));
+ << "text")
+ << "weights"
+ << BSON("d.e.f" << 20));
FTSSpec spec(assertGet(FTSSpec::fixSpec(indexSpec)));
TermFrequencyMap tfm;