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/storage_engine_metadata.cpp | |
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/storage_engine_metadata.cpp')
-rw-r--r-- | src/mongo/db/storage/storage_engine_metadata.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
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, |