diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2015-09-16 08:23:33 -0400 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2015-09-17 05:25:25 -0400 |
commit | b7ac467dbe15275ffcd51f446f9b42491f29e922 (patch) | |
tree | b39273bb2e55c9f20c60adf2837b6bad5ce33ecf /src/mongo/db/repl/optime.cpp | |
parent | aa190f0e2b34d29231b2ddd6660e641821071c1f (diff) | |
download | mongo-b7ac467dbe15275ffcd51f446f9b42491f29e922.tar.gz |
SERVER-19905 consistently use t as the field name for the term portion of an OpTime
Diffstat (limited to 'src/mongo/db/repl/optime.cpp')
-rw-r--r-- | src/mongo/db/repl/optime.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/mongo/db/repl/optime.cpp b/src/mongo/db/repl/optime.cpp index 172302b42c1..92a3c5556ca 100644 --- a/src/mongo/db/repl/optime.cpp +++ b/src/mongo/db/repl/optime.cpp @@ -37,12 +37,9 @@ namespace mongo { namespace repl { -namespace { -const char* kTimestampFieldName = "ts"; -const char* kTermFieldName = "t"; - -} // namespace +const char OpTime::kTimestampFieldName[] = "ts"; +const char OpTime::kTermFieldName[] = "t"; OpTime::OpTime(Timestamp ts, long long term) : _timestamp(std::move(ts)), _term(term) {} @@ -62,16 +59,15 @@ bool OpTime::isNull() const { return _timestamp.isNull(); } -void OpTime::append(BSONObjBuilder* builder) const { - builder->append(kTimestampFieldName, _timestamp); +void OpTime::append(BSONObjBuilder* builder, const std::string& subObjName) const { + BSONObjBuilder opTimeBuilder(builder->subobjStart(subObjName)); + opTimeBuilder.append(kTimestampFieldName, _timestamp); - // Don't add term in protocol version 0. - if (_term != kUninitializedTerm) { - builder->append(kTermFieldName, _term); - } + opTimeBuilder.append(kTermFieldName, _term); + opTimeBuilder.doneFast(); } -StatusWith<OpTime> OpTime::parseFromBSON(const BSONObj& obj) { +StatusWith<OpTime> OpTime::parseFromOplogEntry(const BSONObj& obj) { Timestamp ts; Status status = bsonExtractTimestampField(obj, kTimestampFieldName, &ts); if (!status.isOK()) |