diff options
author | Greg Studer <greg@10gen.com> | 2014-04-18 10:11:47 -0400 |
---|---|---|
committer | Greg Studer <greg@10gen.com> | 2014-05-15 14:23:14 -0400 |
commit | 1e9944fbed01c900cb2d8c7e38b38a7acf9e657b (patch) | |
tree | d3df1bb8243f2efd7764cc541cfdbd1087e0f295 | |
parent | c22fbc9bc636c4c730569c741a2fb6c46193bf5f (diff) | |
download | mongo-1e9944fbed01c900cb2d8c7e38b38a7acf9e657b.tar.gz |
SERVER-11332 ConnectionString less-than for simpler use in maps
(cherry picked from commit 0e3d4410933999e94a5937b08491824138c654d6)
-rw-r--r-- | src/mongo/client/dbclientinterface.h | 6 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batch_write_exec.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batch_write_exec.h | 10 |
3 files changed, 8 insertions, 12 deletions
diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h index b51424232c6..3682fd11ede 100644 --- a/src/mongo/client/dbclientinterface.h +++ b/src/mongo/client/dbclientinterface.h @@ -191,6 +191,7 @@ namespace mongo { */ class MONGO_CLIENT_API ConnectionString { public: + enum ConnectionType { INVALID , MASTER , PAIR , SET , SYNC, CUSTOM }; ConnectionString() { @@ -295,6 +296,11 @@ namespace mongo { return _connectHook; } + // Allows ConnectionStrings to be stored more easily in sets/maps + bool operator<(const ConnectionString& other) const { + return _string < other._string; + } + // // FOR TESTING ONLY - useful to be able to directly mock a connection string without // including the entire client library. diff --git a/src/mongo/s/write_ops/batch_write_exec.cpp b/src/mongo/s/write_ops/batch_write_exec.cpp index 1ed043021c6..0069a2788de 100644 --- a/src/mongo/s/write_ops/batch_write_exec.cpp +++ b/src/mongo/s/write_ops/batch_write_exec.cpp @@ -55,9 +55,7 @@ namespace mongo { // // TODO: Unordered map? - typedef OwnedPointerMap<ConnectionString, - TargetedWriteBatch, - ConnectionStringComp> OwnedHostBatchMap; + typedef OwnedPointerMap<ConnectionString, TargetedWriteBatch> OwnedHostBatchMap; } static void buildErrorFrom( const Status& status, WriteErrorDetail* error ) { diff --git a/src/mongo/s/write_ops/batch_write_exec.h b/src/mongo/s/write_ops/batch_write_exec.h index c74b6b24cde..cb0f63fdb4f 100644 --- a/src/mongo/s/write_ops/batch_write_exec.h +++ b/src/mongo/s/write_ops/batch_write_exec.h @@ -96,14 +96,6 @@ namespace mongo { auto_ptr<BatchWriteExecStats> _stats; }; - // Useful comparator for using connection strings in ordered sets and maps - struct ConnectionStringComp { - bool operator()( const ConnectionString& connStrA, - const ConnectionString& connStrB ) const { - return connStrA.toString().compare( connStrB.toString() ) < 0; - } - }; - struct HostOpTime { HostOpTime(OpTime ot, OID e) : opTime(ot), electionId(e) {}; HostOpTime() {}; @@ -111,7 +103,7 @@ namespace mongo { OID electionId; }; - typedef std::map<ConnectionString, HostOpTime, ConnectionStringComp> HostOpTimeMap; + typedef std::map<ConnectionString, HostOpTime> HostOpTimeMap; class BatchWriteExecStats { public: |