diff options
author | Randolph Tan <randolph@10gen.com> | 2017-09-26 17:45:15 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2017-10-04 16:43:58 -0400 |
commit | 0ab7000e04e16813c1e1e3f131f02de102ddffba (patch) | |
tree | 07c771aa1229bc85755f952dcc9a157a8d4e2dd2 /src/mongo/db/repl/optime.cpp | |
parent | d6267ee66b997af73fcfb095f03f655bb61c06dc (diff) | |
download | mongo-0ab7000e04e16813c1e1e3f131f02de102ddffba.tar.gz |
SERVER-31030 Use full OpTime instead of just Timestamps to refer to oplog entries
Diffstat (limited to 'src/mongo/db/repl/optime.cpp')
-rw-r--r-- | src/mongo/db/repl/optime.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/db/repl/optime.cpp b/src/mongo/db/repl/optime.cpp index 9c63e0a7e88..2957f218374 100644 --- a/src/mongo/db/repl/optime.cpp +++ b/src/mongo/db/repl/optime.cpp @@ -91,6 +91,22 @@ std::ostream& operator<<(std::ostream& out, const OpTime& opTime) { return out << opTime.toString(); } +void OpTime::appendAsQuery(BSONObjBuilder* builder) const { + builder->append(kTimestampFieldName, _timestamp); + if (_term == kUninitializedTerm) { + // pv0 oplogs don't actually have the term field so don't query for {t: -1}. + builder->append(kTermFieldName, BSON("$exists" << false)); + } else { + builder->append(kTermFieldName, _term); + } +} + +BSONObj OpTime::asQuery() const { + BSONObjBuilder builder; + appendAsQuery(&builder); + return builder.obj(); +} + } // namespace repl BSONObjBuilder& operator<<(BSONObjBuilderValueStream& builder, const repl::OpTime& value) { |