diff options
author | Andrew Morrow <acm@mongodb.com> | 2016-03-13 16:44:36 -0400 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2016-03-21 22:55:32 -0400 |
commit | efc57ffd9d4912812d1e1f6649aebd7465fd3e38 (patch) | |
tree | dadab7198eb9a929e9beb9cb98755d528958b331 /src/mongo/bson/util | |
parent | 6877d732e6d5739f9526d89d8e1360c08672eda7 (diff) | |
download | mongo-efc57ffd9d4912812d1e1f6649aebd7465fd3e38.tar.gz |
SERVER-23103 Break circularity between optime and bson_extract
Diffstat (limited to 'src/mongo/bson/util')
-rw-r--r-- | src/mongo/bson/util/SConscript | 2 | ||||
-rw-r--r-- | src/mongo/bson/util/bson_extract.cpp | 19 | ||||
-rw-r--r-- | src/mongo/bson/util/bson_extract.h | 15 | ||||
-rw-r--r-- | src/mongo/bson/util/bson_extract_test.cpp | 27 |
4 files changed, 0 insertions, 63 deletions
diff --git a/src/mongo/bson/util/SConscript b/src/mongo/bson/util/SConscript index 6aa6c1476c8..6c8ce51e012 100644 --- a/src/mongo/bson/util/SConscript +++ b/src/mongo/bson/util/SConscript @@ -9,7 +9,6 @@ env.Library( ], LIBDEPS=[ '$BUILD_DIR/mongo/base', - '$BUILD_DIR/mongo/db/repl/optime', ], ) @@ -20,7 +19,6 @@ env.CppUnitTest( ], LIBDEPS=[ '$BUILD_DIR/mongo/base', - '$BUILD_DIR/mongo/db/repl/optime', 'bson_extract', ], ) diff --git a/src/mongo/bson/util/bson_extract.cpp b/src/mongo/bson/util/bson_extract.cpp index 4caaf700406..095185e4baa 100644 --- a/src/mongo/bson/util/bson_extract.cpp +++ b/src/mongo/bson/util/bson_extract.cpp @@ -98,25 +98,6 @@ Status bsonExtractStringField(const BSONObj& object, StringData fieldName, std:: return Status::OK(); } -Status bsonExtractOpTimeField(const BSONObj& object, StringData fieldName, repl::OpTime* out) { - BSONElement element; - Status status = bsonExtractTypedField(object, fieldName, Object, &element); - if (!status.isOK()) - return status; - - BSONObj opTimeObj = element.Obj(); - Timestamp ts; - status = bsonExtractTimestampField(opTimeObj, repl::OpTime::kTimestampFieldName, &ts); - if (!status.isOK()) - return status; - long long term; - status = bsonExtractIntegerField(opTimeObj, repl::OpTime::kTermFieldName, &term); - if (!status.isOK()) - return status; - *out = repl::OpTime(ts, term); - return Status::OK(); -} - Status bsonExtractTimestampField(const BSONObj& object, StringData fieldName, Timestamp* out) { BSONElement element; Status status = bsonExtractTypedField(object, fieldName, bsonTimestamp, &element); diff --git a/src/mongo/bson/util/bson_extract.h b/src/mongo/bson/util/bson_extract.h index ddc571d99aa..a2189a4d57b 100644 --- a/src/mongo/bson/util/bson_extract.h +++ b/src/mongo/bson/util/bson_extract.h @@ -33,7 +33,6 @@ #include "mongo/base/status.h" #include "mongo/base/string_data.h" #include "mongo/bson/bsontypes.h" -#include "mongo/db/repl/optime.h" #include "mongo/stdx/functional.h" namespace mongo { @@ -96,20 +95,6 @@ Status bsonExtractIntegerField(const BSONObj& object, StringData fieldName, long */ Status bsonExtractStringField(const BSONObj& object, StringData fieldName, std::string* out); - -/** - * Finds an object-typed field named "fieldName" in "object" that represents an OpTime. - * - * The OpTime objects have two fields, a Timestamp ts and numeric term. - * - * Returns Status::OK() and sets *out to the found element's OpTime value on success. Returns - * ErrorCodes::NoSuchKey if there are no matches for "fieldName" or either subobject field is - * missing, and ErrorCodes::TypeMismatch if the type of the matching element is not Object, the ts - * subfield is not Timestamp, or the term subfield is not numeric. For return values other than - * Status::OK(), the resulting value of "*out" is undefined. - */ -Status bsonExtractOpTimeField(const BSONObj& object, StringData fieldName, repl::OpTime* out); - /** * Finds an Timestamp-typed element named "fieldName" in "object" and stores its value in "out". * diff --git a/src/mongo/bson/util/bson_extract_test.cpp b/src/mongo/bson/util/bson_extract_test.cpp index 0c7cb031edb..8ec13d1fbd1 100644 --- a/src/mongo/bson/util/bson_extract_test.cpp +++ b/src/mongo/bson/util/bson_extract_test.cpp @@ -86,33 +86,6 @@ TEST(ExtractBSON, ExtractStringFieldWithDefault) { ASSERT_EQUALS(std::string("default"), s); } -TEST(ExtractBSON, ExtractOpTimeField) { - // Outer object cases. - BSONObj obj = BSON("a" << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "b" - << "notAnObj"); - repl::OpTime opTime; - ASSERT_OK(bsonExtractOpTimeField(obj, "a", &opTime)); - ASSERT(repl::OpTime(Timestamp(10, 0), 2) == opTime); - ASSERT_EQUALS(ErrorCodes::TypeMismatch, bsonExtractOpTimeField(obj, "b", &opTime)); - ASSERT_EQUALS(ErrorCodes::NoSuchKey, bsonExtractOpTimeField(obj, "c", &opTime)); - - // Missing timestamp field. - obj = BSON("a" << BSON("ts" - << "notATimestamp" - << "t" << 2)); - ASSERT_EQUALS(ErrorCodes::TypeMismatch, bsonExtractOpTimeField(obj, "a", &opTime)); - // Wrong typed timestamp field. - obj = BSON("a" << BSON("t" << 2)); - ASSERT_EQUALS(ErrorCodes::NoSuchKey, bsonExtractOpTimeField(obj, "a", &opTime)); - // Missing term field. - obj = BSON("a" << BSON("ts" << Timestamp(10, 0) << "t" - << "notANumber")); - ASSERT_EQUALS(ErrorCodes::TypeMismatch, bsonExtractOpTimeField(obj, "a", &opTime)); - // Wrong typed term field. - obj = BSON("a" << BSON("ts" << Timestamp(10, 0))); - ASSERT_EQUALS(ErrorCodes::NoSuchKey, bsonExtractOpTimeField(obj, "a", &opTime)); -} - TEST(ExtractBSON, ExtractBooleanFieldWithDefault) { BSONObj obj1 = BSON("a" << 1 << "b" << "hello" |