diff options
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r-- | src/mongo/db/index/btree_key_generator.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/index/btree_key_generator_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/index/expression_params.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/index/index_build_interceptor.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/index/index_build_interceptor.h | 6 | ||||
-rw-r--r-- | src/mongo/db/index/index_descriptor.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/index/s2_access_method.cpp | 36 | ||||
-rw-r--r-- | src/mongo/db/index/s2_key_generator_test.cpp | 21 | ||||
-rw-r--r-- | src/mongo/db/index/sort_key_generator_test.cpp | 3 |
9 files changed, 31 insertions, 66 deletions
diff --git a/src/mongo/db/index/btree_key_generator.cpp b/src/mongo/db/index/btree_key_generator.cpp index f1c860f4cfc..7f337879d9d 100644 --- a/src/mongo/db/index/btree_key_generator.cpp +++ b/src/mongo/db/index/btree_key_generator.cpp @@ -98,9 +98,7 @@ BSONElement BtreeKeyGenerator::_extractNextElement(const BSONObj& obj, 16746, str::stream() << "Ambiguous field name found in array (do not use numeric field names in " "embedded elements in an array), field: '" - << arrField.fieldName() - << "' for array: " - << positionalInfo.arrayObj, + << arrField.fieldName() << "' for array: " << positionalInfo.arrayObj, !haveObjField || !positionalInfo.hasPositionallyIndexedElt()); *arrayNestedArray = false; diff --git a/src/mongo/db/index/btree_key_generator_test.cpp b/src/mongo/db/index/btree_key_generator_test.cpp index 3301cc3c861..da569fdb203 100644 --- a/src/mongo/db/index/btree_key_generator_test.cpp +++ b/src/mongo/db/index/btree_key_generator_test.cpp @@ -43,9 +43,9 @@ #include "mongo/util/log.h" using namespace mongo; -using std::unique_ptr; using std::cout; using std::endl; +using std::unique_ptr; using std::vector; namespace { diff --git a/src/mongo/db/index/expression_params.cpp b/src/mongo/db/index/expression_params.cpp index e47ef01a5e6..4dc0ebbb8d9 100644 --- a/src/mongo/db/index/expression_params.cpp +++ b/src/mongo/db/index/expression_params.cpp @@ -193,14 +193,8 @@ void ExpressionParams::initialize2dsphereParams(const BSONObj& infoObj, massert(17395, stream() << "unsupported geo index version { " << kIndexVersionFieldName << " : " - << out->indexVersion - << " }, only support versions: [" - << S2_INDEX_VERSION_1 - << "," - << S2_INDEX_VERSION_2 - << "," - << S2_INDEX_VERSION_3 - << "]", + << out->indexVersion << " }, only support versions: [" << S2_INDEX_VERSION_1 + << "," << S2_INDEX_VERSION_2 << "," << S2_INDEX_VERSION_3 << "]", out->indexVersion == S2_INDEX_VERSION_3 || out->indexVersion == S2_INDEX_VERSION_2 || out->indexVersion == S2_INDEX_VERSION_1); } diff --git a/src/mongo/db/index/index_build_interceptor.cpp b/src/mongo/db/index/index_build_interceptor.cpp index f308c4251cb..fc6f6067484 100644 --- a/src/mongo/db/index/index_build_interceptor.cpp +++ b/src/mongo/db/index/index_build_interceptor.cpp @@ -397,8 +397,8 @@ Status IndexBuildInterceptor::sideWrite(OperationContext* opCtx, // other writes making up this operation are given. When index builds can cope with // replication rollbacks, side table writes associated with a CUD operation should // remain/rollback along with the corresponding oplog entry. - toInsert.emplace_back(BSON( - "op" << (op == Op::kInsert ? "i" : "d") << "key" << key << "recordId" << loc.repr())); + toInsert.emplace_back(BSON("op" << (op == Op::kInsert ? "i" : "d") << "key" << key + << "recordId" << loc.repr())); } if (op == Op::kInsert) { @@ -408,9 +408,7 @@ Status IndexBuildInterceptor::sideWrite(OperationContext* opCtx, for (const auto& key : multikeyMetadataKeys) { toInsert.emplace_back(BSON("op" << "i" - << "key" - << key - << "recordId" + << "key" << key << "recordId" << static_cast<int64_t>( RecordId::ReservedId::kWildcardMultikeyMetadataId))); } @@ -421,7 +419,7 @@ Status IndexBuildInterceptor::sideWrite(OperationContext* opCtx, // operations outside this table and in the same transaction are rolled back, this counter also // needs to be rolled back. opCtx->recoveryUnit()->onRollback( - [ this, size = toInsert.size() ] { _sideWritesCounter.fetchAndSubtract(size); }); + [this, size = toInsert.size()] { _sideWritesCounter.fetchAndSubtract(size); }); std::vector<Record> records; for (auto& doc : toInsert) { diff --git a/src/mongo/db/index/index_build_interceptor.h b/src/mongo/db/index/index_build_interceptor.h index 18f98cc72cf..f8afcd4f56a 100644 --- a/src/mongo/db/index/index_build_interceptor.h +++ b/src/mongo/db/index/index_build_interceptor.h @@ -121,9 +121,9 @@ public: bool areAllConstraintsChecked(OperationContext* opCtx) const; /** - * When an index builder wants to commit, use this to retrieve any recorded multikey paths - * that were tracked during the build. - */ + * When an index builder wants to commit, use this to retrieve any recorded multikey paths + * that were tracked during the build. + */ boost::optional<MultikeyPaths> getMultikeyPaths() const; const std::string& getSideWritesTableIdent() const; diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp index c88a81c305b..da27ca8a2e5 100644 --- a/src/mongo/db/index/index_descriptor.cpp +++ b/src/mongo/db/index/index_descriptor.cpp @@ -63,7 +63,7 @@ void populateOptionsMap(std::map<StringData, BSONElement>& theMap, const BSONObj fieldName == IndexDescriptor::kDropDuplicatesFieldName || // this is now ignored fieldName == IndexDescriptor::kSparseFieldName || // checked specially fieldName == IndexDescriptor::kUniqueFieldName // check specially - ) { + ) { continue; } theMap[fieldName] = e; @@ -152,8 +152,7 @@ Status IndexDescriptor::isIndexVersionAllowedForCreation( } return {ErrorCodes::CannotCreateIndex, str::stream() << "Invalid index specification " << indexSpec - << "; cannot create an index with v=" - << static_cast<int>(indexVersion)}; + << "; cannot create an index with v=" << static_cast<int>(indexVersion)}; } IndexVersion IndexDescriptor::getDefaultIndexVersion() { diff --git a/src/mongo/db/index/s2_access_method.cpp b/src/mongo/db/index/s2_access_method.cpp index 3f9ac46d57e..6881641b23b 100644 --- a/src/mongo/db/index/s2_access_method.cpp +++ b/src/mongo/db/index/s2_access_method.cpp @@ -97,30 +97,18 @@ StatusWith<BSONObj> S2AccessMethod::fixSpec(const BSONObj& specObj) { if (!indexVersionElt.isNumber()) { return {ErrorCodes::CannotCreateIndex, str::stream() << "Invalid type for geo index version { " << kIndexVersionFieldName - << " : " - << indexVersionElt - << " }, only versions: [" - << S2_INDEX_VERSION_1 - << "," - << S2_INDEX_VERSION_2 - << "," - << S2_INDEX_VERSION_3 - << "] are supported"}; + << " : " << indexVersionElt << " }, only versions: [" + << S2_INDEX_VERSION_1 << "," << S2_INDEX_VERSION_2 << "," + << S2_INDEX_VERSION_3 << "] are supported"}; } if (indexVersionElt.type() == BSONType::NumberDouble && !std::isnormal(indexVersionElt.numberDouble())) { return {ErrorCodes::CannotCreateIndex, str::stream() << "Invalid value for geo index version { " << kIndexVersionFieldName - << " : " - << indexVersionElt - << " }, only versions: [" - << S2_INDEX_VERSION_1 - << "," - << S2_INDEX_VERSION_2 - << "," - << S2_INDEX_VERSION_3 - << "] are supported"}; + << " : " << indexVersionElt << " }, only versions: [" + << S2_INDEX_VERSION_1 << "," << S2_INDEX_VERSION_2 << "," + << S2_INDEX_VERSION_3 << "] are supported"}; } const auto indexVersion = indexVersionElt.numberLong(); @@ -128,15 +116,9 @@ StatusWith<BSONObj> S2AccessMethod::fixSpec(const BSONObj& specObj) { indexVersion != S2_INDEX_VERSION_3) { return {ErrorCodes::CannotCreateIndex, str::stream() << "unsupported geo index version { " << kIndexVersionFieldName - << " : " - << indexVersionElt - << " }, only versions: [" - << S2_INDEX_VERSION_1 - << "," - << S2_INDEX_VERSION_2 - << "," - << S2_INDEX_VERSION_3 - << "] are supported"}; + << " : " << indexVersionElt << " }, only versions: [" + << S2_INDEX_VERSION_1 << "," << S2_INDEX_VERSION_2 << "," + << S2_INDEX_VERSION_3 << "] are supported"}; } return specObj; diff --git a/src/mongo/db/index/s2_key_generator_test.cpp b/src/mongo/db/index/s2_key_generator_test.cpp index b57a2b58c43..93fc8ac545d 100644 --- a/src/mongo/db/index/s2_key_generator_test.cpp +++ b/src/mongo/db/index/s2_key_generator_test.cpp @@ -99,8 +99,7 @@ void assertMultikeyPathsEqual(const MultikeyPaths& expectedMultikeyPaths, const MultikeyPaths& actualMultikeyPaths) { if (expectedMultikeyPaths != actualMultikeyPaths) { FAIL(str::stream() << "Expected: " << dumpMultikeyPaths(expectedMultikeyPaths) - << ", Actual: " - << dumpMultikeyPaths(actualMultikeyPaths)); + << ", Actual: " << dumpMultikeyPaths(actualMultikeyPaths)); } } @@ -109,13 +108,11 @@ long long getCellID(int x, int y, bool multiPoint = false) { if (multiPoint) { obj = BSON("a" << BSON("type" << "MultiPoint" - << "coordinates" - << BSON_ARRAY(BSON_ARRAY(x << y)))); + << "coordinates" << BSON_ARRAY(BSON_ARRAY(x << y)))); } else { obj = BSON("a" << BSON("type" << "Point" - << "coordinates" - << BSON_ARRAY(x << y))); + << "coordinates" << BSON_ARRAY(x << y))); } BSONObj keyPattern = fromjson("{a: '2dsphere'}"); BSONObj infoObj = fromjson("{key: {a: '2dsphere'}, '2dsphereIndexVersion': 3}"); @@ -244,8 +241,7 @@ TEST(S2KeyGeneratorTest, CollationAppliedToNonGeoStringFieldBeforeGeoField) { BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet(); expectedKeys.insert(BSON("" << "gnirts" - << "" - << getCellID(0, 0))); + << "" << getCellID(0, 0))); assertKeysetsEqual(expectedKeys, actualKeys); assertMultikeyPathsEqual(MultikeyPaths{std::set<size_t>{}, std::set<size_t>{}}, @@ -267,9 +263,7 @@ TEST(S2KeyGeneratorTest, CollationAppliedToAllNonGeoStringFields) { BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet(); expectedKeys.insert(BSON("" << "gnirts" - << "" - << getCellID(0, 0) - << "" + << "" << getCellID(0, 0) << "" << "2gnirts")); assertKeysetsEqual(expectedKeys, actualKeys); @@ -389,8 +383,9 @@ TEST(S2KeyGeneratorTest, CollationAppliedToStringsInNestedObjects) { ExpressionKeysPrivate::getS2Keys(obj, keyPattern, params, &actualKeys, &actualMultikeyPaths); BSONObjSet expectedKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet(); - expectedKeys.insert(BSON("" << getCellID(0, 0) << "" << BSON("c" - << "gnirts"))); + expectedKeys.insert(BSON("" << getCellID(0, 0) << "" + << BSON("c" + << "gnirts"))); assertKeysetsEqual(expectedKeys, actualKeys); assertMultikeyPathsEqual(MultikeyPaths{std::set<size_t>{}, std::set<size_t>{}}, diff --git a/src/mongo/db/index/sort_key_generator_test.cpp b/src/mongo/db/index/sort_key_generator_test.cpp index 7801c911bd9..e7dd4ec822f 100644 --- a/src/mongo/db/index/sort_key_generator_test.cpp +++ b/src/mongo/db/index/sort_key_generator_test.cpp @@ -150,8 +150,7 @@ DEATH_TEST(SortKeyGeneratorTest, MONGO_COMPILER_VARIABLE_UNUSED auto ignored = std::make_unique<SortKeyGenerator>(BSON("a" << BSON("$meta" << "textScore" - << "extra" - << 1)), + << "extra" << 1)), nullptr); } |