diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2016-06-03 13:26:35 -0400 |
---|---|---|
committer | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2016-06-03 13:26:35 -0400 |
commit | cecbe424d32cbb475d9b0384d29b98a9fba9c89f (patch) | |
tree | 0ce2632b078fee8865f15a56cf07c684a8260c21 /src/mongo/db/storage | |
parent | 8900002b731358b0beedadb2ceb4e3156de402b6 (diff) | |
download | mongo-cecbe424d32cbb475d9b0384d29b98a9fba9c89f.tar.gz |
SERVER-23114 Move functions involving dotted paths to separate library.
The ability to specify a dotted path (e.g. "a.b") to traverse through
embedded objects and array elements isn't defined in the BSON
specification and so it doesn't belong in our BSON library.
The following functions have been defined within a 'dotted_path_support'
namespace and accept an additional BSONObj as their first argument to
replace the associated method on the BSONObj class.
- extractElementAtPath() is functionally equivalent to
BSONObj::getFieldDotted().
- extractElementAtPathOrArrayAlongPath() is functionally equivalent to
BSONObj::getFieldDottedOrArray().
- extractAllElementsAlongPath() is functionally equivalent to
BSONObj::getFieldsDotted().
- extractElementsBasedOnTemplate() is functionally equivalent to
BSONObj::extractFields().
- compareObjectsAccordingToSort() is functionally equivalent to
BSONObj::woSortOrder().
Diffstat (limited to 'src/mongo/db/storage')
-rw-r--r-- | src/mongo/db/storage/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/storage/storage_engine_metadata.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/SConscript | 3 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 8 |
4 files changed, 14 insertions, 5 deletions
diff --git a/src/mongo/db/storage/SConscript b/src/mongo/db/storage/SConscript index c2b6ae9e5e4..4680e07f672 100644 --- a/src/mongo/db/storage/SConscript +++ b/src/mongo/db/storage/SConscript @@ -175,6 +175,7 @@ env.Library( ], LIBDEPS=[ '$BUILD_DIR/mongo/base', + '$BUILD_DIR/mongo/db/bson/dotted_path_support', ] ) diff --git a/src/mongo/db/storage/storage_engine_metadata.cpp b/src/mongo/db/storage/storage_engine_metadata.cpp index 144ba7c838b..9b5c74ba2a5 100644 --- a/src/mongo/db/storage/storage_engine_metadata.cpp +++ b/src/mongo/db/storage/storage_engine_metadata.cpp @@ -40,6 +40,7 @@ #include <ostream> #include <vector> +#include "mongo/db/bson/dotted_path_support.h" #include "mongo/db/jsobj.h" #include "mongo/util/assert_util.h" #include "mongo/util/log.h" @@ -47,6 +48,8 @@ namespace mongo { +namespace dps = ::mongo::dotted_path_support; + namespace { const std::string kMetadataBasename = "storage.bson"; @@ -172,7 +175,7 @@ Status StorageEngineMetadata::read() { } // Validate 'storage.engine' field. - BSONElement storageEngineElement = obj.getFieldDotted("storage.engine"); + BSONElement storageEngineElement = dps::extractElementAtPath(obj, "storage.engine"); if (storageEngineElement.type() != mongo::String) { return Status(ErrorCodes::FailedToParse, str::stream() << "The 'storage.engine' field in metadata must be a string: " @@ -188,7 +191,7 @@ Status StorageEngineMetadata::read() { _storageEngine = storageEngine; // Read storage engine options generated by storage engine factory from startup options. - BSONElement storageEngineOptionsElement = obj.getFieldDotted("storage.options"); + BSONElement storageEngineOptionsElement = dps::extractElementAtPath(obj, "storage.options"); if (!storageEngineOptionsElement.eoo()) { if (!storageEngineOptionsElement.isABSONObj()) { return Status(ErrorCodes::FailedToParse, diff --git a/src/mongo/db/storage/wiredtiger/SConscript b/src/mongo/db/storage/wiredtiger/SConscript index 20d170ac8a5..ca266e4ce74 100644 --- a/src/mongo/db/storage/wiredtiger/SConscript +++ b/src/mongo/db/storage/wiredtiger/SConscript @@ -41,11 +41,12 @@ if wiredtiger: LIBDEPS= [ 'storage_wiredtiger_customization_hooks', '$BUILD_DIR/mongo/base', - '$BUILD_DIR/mongo/db/namespace_string', + '$BUILD_DIR/mongo/db/bson/dotted_path_support', '$BUILD_DIR/mongo/db/catalog/collection_options', '$BUILD_DIR/mongo/db/concurrency/lock_manager', '$BUILD_DIR/mongo/db/concurrency/write_conflict_exception', '$BUILD_DIR/mongo/db/index/index_descriptor', + '$BUILD_DIR/mongo/db/namespace_string', '$BUILD_DIR/mongo/db/service_context', '$BUILD_DIR/mongo/db/storage/index_entry_comparison', '$BUILD_DIR/mongo/db/storage/journal_listener', diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 02914421a15..8c51bf5689d 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -43,6 +43,7 @@ #include "mongo/base/error_codes.h" #include "mongo/bson/bsonobjbuilder.h" +#include "mongo/db/bson/dotted_path_support.h" #include "mongo/db/catalog/collection_catalog_entry.h" #include "mongo/db/client.h" #include "mongo/db/commands/server_status_metric.h" @@ -78,6 +79,8 @@ namespace mongo { using std::set; using std::string; +namespace dps = ::mongo::dotted_path_support; + class WiredTigerKVEngine::WiredTigerJournalFlusher : public BackgroundJob { public: explicit WiredTigerJournalFlusher(WiredTigerSessionCache* sessionCache) @@ -509,8 +512,9 @@ Status WiredTigerKVEngine::createSortedDataInterface(OperationContext* opCtx, if (!collOptions.indexOptionDefaults["storageEngine"].eoo()) { BSONObj storageEngineOptions = collOptions.indexOptionDefaults["storageEngine"].Obj(); - collIndexOptions = storageEngineOptions.getFieldDotted(_canonicalName + ".configString") - .valuestrsafe(); + collIndexOptions = + dps::extractElementAtPath(storageEngineOptions, _canonicalName + ".configString") + .valuestrsafe(); } } |