diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-06-04 11:38:29 +0100 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-06-07 14:27:28 +0300 |
commit | 06369c8cedbb06a554012069c8973423b32d9452 (patch) | |
tree | 63fa7e876a688ddeb38223239fa1517c3635b37e | |
parent | 8df6a4a4f4494d5371ccafcc3571a296b5fd384d (diff) | |
download | mongo-06369c8cedbb06a554012069c8973423b32d9452.tar.gz |
SERVER-29464 Get rid of BSONSerializable
-rw-r--r-- | src/mongo/db/field_parser.h | 47 | ||||
-rw-r--r-- | src/mongo/s/bson_serializable.h | 103 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batch_write_exec.cpp | 12 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batch_write_op.cpp | 16 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batched_command_request.cpp | 71 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batched_command_request.h | 16 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batched_command_response.cpp | 5 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batched_command_response.h | 29 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batched_delete_document.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batched_delete_document.h | 27 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batched_update_document.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batched_update_document.h | 23 |
12 files changed, 79 insertions, 274 deletions
diff --git a/src/mongo/db/field_parser.h b/src/mongo/db/field_parser.h index 376bd66f561..20840c57f2a 100644 --- a/src/mongo/db/field_parser.h +++ b/src/mongo/db/field_parser.h @@ -216,12 +216,9 @@ public: // TODO: BSONElement extraction of types below /** - * Extracts a mandatory BSONSerializable structure 'field' from the object 'doc'. Write - * the extracted contents to '*out' if successful or fills '*errMsg', if exising, - * otherwise. This variant relies on T having a parseBSON, which all - * BSONSerializable's have. - * - * TODO: Tighten for BSONSerializable's only + * Extracts a mandatory 'field' from the object 'doc'. Writes the extracted contents to '*out' + * if successful or fills '*errMsg', if exising, otherwise. This variant relies on T having a + * parseBSON method. */ template <typename T> static FieldState extract(BSONObj doc, @@ -229,19 +226,17 @@ public: T* out, std::string* errMsg = NULL); + /** + * Similar to the mandatory 'extract' but on a optional field. The '*out' value would only be + * allocated if the field is present. The ownership of '*out' would be transferred to the + * caller, in that case. + */ template <typename T> static FieldState extract(BSONObj doc, const BSONField<T*>& field, T** out, std::string* errMsg = NULL); - /** - * Similar to the mandatory 'extract' but on a optional field. '*out' would only be - * allocated if the field is present. The ownership of '*out' would be transferred to - * the caller, in that case. - * - * TODO: Tighten for BSONSerializable's only - */ template <typename T> static FieldState extract(BSONObj doc, const BSONField<T>& field, @@ -249,14 +244,11 @@ public: std::string* errMsg = NULL); /** - * Extracts a mandatory repetition of BSONSerializable structures, 'field', from the - * object 'doc'. Write the extracted contents to '*out' if successful or fills - * '*errMsg', if exising, otherwise. This variant relies on T having a parseBSON, - * which all BSONSerializable's have. + * Extracts a mandatory repetition of 'field', from the object 'doc'. Writes the extracted + * contents to '*out' if successful or fills '*errMsg', if exising, otherwise. This variant + * relies on T having a parseBSON method. * * The vector owns the instances of T. - * - * TODO: Tighten for BSONSerializable's only */ template <typename T> static FieldState extract(BSONObj doc, @@ -265,14 +257,11 @@ public: std::string* errMsg = NULL); /** - * Extracts a mandatory repetition of BSONSerializable structures, 'field', from the - * field 'elem'. Write the extracted contents to '*out' if successful or fills - * '*errMsg', if exising, otherwise. This variant relies on T having a parseBSON, - * which all BSONSerializable's have. + * Extracts a mandatory repetition of 'field', from the field 'elem'. Writes the extracted + * contents to '*out' if successful or fills '*errMsg', if exising, otherwise. This variant + * relies on T having a parseBSON method. * * The vector owns the instances of T. - * - * TODO: Tighten for BSONSerializable's only */ template <typename T> static FieldState extract(BSONElement elem, @@ -281,13 +270,11 @@ public: std::string* errMsg = NULL); /** - * Similar to the mandatory repetition' extract but on an optional field. '*out' would - * only be allocated if the field is present. The ownership of '*out' would be - * transferred to the caller, in that case. + * Similar to the mandatory repetition' extract but on an optional field. The '*out' value would + * only be allocated if the field is present. The ownership of '*out' would be transferred to + * the caller, in that case. * * The vector owns the instances of T. - * - * TODO: Tighten for BSONSerializable's only */ template <typename T> static FieldState extract(BSONObj doc, diff --git a/src/mongo/s/bson_serializable.h b/src/mongo/s/bson_serializable.h deleted file mode 100644 index 53a2a7f695a..00000000000 --- a/src/mongo/s/bson_serializable.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (C) 2013 10gen Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the GNU Affero General Public License in all respects - * for all of the code used other than as permitted herein. If you modify - * file(s) with this exception, you may extend this exception to your - * version of the file(s), but you are not obligated to do so. If you do not - * wish to do so, delete this exception statement from your version. If you - * delete this exception statement from all source files in the program, - * then also delete it in the license file. - */ - -#pragma once - -#include <string> - -#include "mongo/db/jsobj.h" - -namespace mongo { - -/** - * "Types" are the interface to a known data structure that will be deserialized from BSON. - */ -class BSONSerializable { -public: - virtual ~BSONSerializable() {} - - /** - * Returns true if all the mandatory fields are present and have valid - * representations. Otherwise returns false and fills in the optional 'errMsg' string. - */ - virtual bool isValid(std::string* errMsg) const = 0; - - /** - * Clears and populates the internal state using the 'source' BSON object if the - * latter contains valid values. Otherwise sets errMsg and returns false. - */ - virtual bool parseBSON(const BSONObj& source, std::string* errMsg) = 0; - - /** Clears the internal state. */ - virtual void clear() = 0; - - /** Returns a std::string representation of the current internal state. */ - virtual std::string toString() const = 0; -}; - -/** - * Generic implementation which accepts and stores any BSON object - * - * Generally this should only be used for compatibility reasons - newer requests should be - * fully typed. - */ -class RawBSONSerializable : public BSONSerializable { -public: - RawBSONSerializable() {} - - explicit RawBSONSerializable(const BSONObj& raw) : _raw(raw) {} - - virtual ~RawBSONSerializable() {} - - virtual bool isValid(std::string* errMsg) const { - return true; - } - - virtual BSONObj toBSON() const { - return _raw; - } - - virtual bool parseBSON(const BSONObj& source, std::string* errMsg) { - _raw = source.getOwned(); - return true; - } - - virtual void clear() { - _raw = BSONObj(); - } - - virtual std::string toString() const { - return toBSON().toString(); - } - -private: - BSONObj _raw; -}; - - -} // namespace mongo diff --git a/src/mongo/s/write_ops/batch_write_exec.cpp b/src/mongo/s/write_ops/batch_write_exec.cpp index 49444a9da68..d7bd2c06f0a 100644 --- a/src/mongo/s/write_ops/batch_write_exec.cpp +++ b/src/mongo/s/write_ops/batch_write_exec.cpp @@ -159,16 +159,16 @@ void BatchWriteExec::executeBatch(OperationContext* opCtx, vector<AsyncRequestsSender::Request> requests; // Get as many batches as we can at once - for (auto it = childBatches.begin(); it != childBatches.end(); ++it) { + for (auto childBatch : childBatches) { + TargetedWriteBatch* const nextBatch = childBatch.second; - TargetedWriteBatch* nextBatch = it->second; - - // If the batch is NULL, we sent it previously, so skip - if (nextBatch == NULL) + // If the batch is nullptr, we sent it previously, so skip + if (!nextBatch) continue; // If we already have a batch for this shard, wait until the next time ShardId targetShardId = nextBatch->getEndpoint().shardName; + OwnedShardBatchMap::MapType::iterator pendingIt = pendingBatches.find(targetShardId); if (pendingIt != pendingBatches.end()) @@ -191,7 +191,7 @@ void BatchWriteExec::executeBatch(OperationContext* opCtx, // We'll only get duplicate hostEndpoints if we have broadcast and non-broadcast // endpoints for the same host, so this should be pretty efficient without // moving stuff around. - it->second = NULL; + childBatch.second = NULL; // Recv-side is responsible for cleaning up the nextBatch when used pendingBatches.insert(make_pair(targetShardId, nextBatch)); diff --git a/src/mongo/s/write_ops/batch_write_op.cpp b/src/mongo/s/write_ops/batch_write_op.cpp index 13d088c57aa..ec2e7391c0e 100644 --- a/src/mongo/s/write_ops/batch_write_op.cpp +++ b/src/mongo/s/write_ops/batch_write_op.cpp @@ -405,13 +405,10 @@ void BatchWriteOp::buildBatchRequest(const TargetedWriteBatch& targetedBatch, request->setNS(_clientRequest.getNS()); request->setShouldBypassValidation(_clientRequest.shouldBypassValidation()); - const vector<TargetedWrite*>& targetedWrites = targetedBatch.getWrites(); + const auto batchType = _clientRequest.getBatchType(); - for (vector<TargetedWrite*>::const_iterator it = targetedWrites.begin(); - it != targetedWrites.end(); - ++it) { - const WriteOpRef& writeOpRef = (*it)->writeOpRef; - BatchedCommandRequest::BatchType batchType = _clientRequest.getBatchType(); + for (auto& targetedWrite : targetedBatch.getWrites()) { + const WriteOpRef& writeOpRef = targetedWrite->writeOpRef; // NOTE: We copy the batch items themselves here from the client request // TODO: This could be inefficient, maybe we want to just reference in the future @@ -424,19 +421,20 @@ void BatchWriteOp::buildBatchRequest(const TargetedWriteBatch& targetedBatch, BatchedUpdateDocument* updateDoc = new BatchedUpdateDocument; clientUpdateRequest->getUpdatesAt(writeOpRef.first)->cloneTo(updateDoc); request->getUpdateRequest()->addToUpdates(updateDoc); - } else { - dassert(batchType == BatchedCommandRequest::BatchType_Delete); + } else if (batchType == BatchedCommandRequest::BatchType_Delete) { BatchedDeleteRequest* clientDeleteRequest = _clientRequest.getDeleteRequest(); BatchedDeleteDocument* deleteDoc = new BatchedDeleteDocument; clientDeleteRequest->getDeletesAt(writeOpRef.first)->cloneTo(deleteDoc); request->getDeleteRequest()->addToDeletes(deleteDoc); + } else { + MONGO_UNREACHABLE; } // TODO: We can add logic here to allow aborting individual ops // if ( NULL == response ) { // ->responses.erase( it++ ); // continue; - //} + // } } if (_clientRequest.isWriteConcernSet()) { diff --git a/src/mongo/s/write_ops/batched_command_request.cpp b/src/mongo/s/write_ops/batched_command_request.cpp index b4b2b13133d..572dae960bd 100644 --- a/src/mongo/s/write_ops/batched_command_request.cpp +++ b/src/mongo/s/write_ops/batched_command_request.cpp @@ -36,10 +36,6 @@ namespace mongo { -using std::unique_ptr; -using std::string; -using std::vector; - const size_t BatchedCommandRequest::kMaxWriteBatchSize = 1000; BatchedCommandRequest::BatchedCommandRequest(BatchType batchType) : _batchType(batchType) { @@ -71,10 +67,6 @@ BatchedCommandRequest::BatchedCommandRequest(BatchType batchType) : _batchType(b } \ } -BatchedCommandRequest::BatchType BatchedCommandRequest::getBatchType() const { - return _batchType; -} - BatchedInsertRequest* BatchedCommandRequest::getInsertRequest() const { return _insertReq.get(); } @@ -103,8 +95,8 @@ bool BatchedCommandRequest::isUniqueIndexRequest() const { return extractUniqueIndex(getInsertRequest()->getDocumentsAt(0)); } -bool BatchedCommandRequest::isValidIndexRequest(string* errMsg) const { - string dummy; +bool BatchedCommandRequest::isValidIndexRequest(std::string* errMsg) const { + std::string dummy; if (!errMsg) errMsg = &dummy; dassert(isInsertIndexRequest()); @@ -130,7 +122,7 @@ bool BatchedCommandRequest::isValidIndexRequest(string* errMsg) const { return true; } -string BatchedCommandRequest::getTargetingNS() const { +std::string BatchedCommandRequest::getTargetingNS() const { return getTargetingNSS().toString(); } @@ -164,29 +156,6 @@ bool BatchedCommandRequest::isVerboseWC() const { return false; } -void BatchedCommandRequest::cloneTo(BatchedCommandRequest* other) const { - other->_insertReq.reset(); - other->_updateReq.reset(); - other->_deleteReq.reset(); - other->_batchType = _batchType; - - switch (getBatchType()) { - case BatchedCommandRequest::BatchType_Insert: - other->_insertReq.reset(new BatchedInsertRequest); - _insertReq->cloneTo(other->_insertReq.get()); - return; - case BatchedCommandRequest::BatchType_Update: - other->_updateReq.reset(new BatchedUpdateRequest); - _updateReq->cloneTo(other->_updateReq.get()); - return; - default: - dassert(getBatchType() == BatchedCommandRequest::BatchType_Delete); - other->_deleteReq.reset(new BatchedDeleteRequest); - _deleteReq->cloneTo(other->_deleteReq.get()); - return; - } -} - bool BatchedCommandRequest::isValid(std::string* errMsg) const { INVOKE(isValid, errMsg); } @@ -324,16 +293,17 @@ bool BatchedCommandRequest::shouldBypassValidation() const { BatchedCommandRequest* BatchedCommandRequest::cloneWithIds( const BatchedCommandRequest& origCmdRequest) { if (origCmdRequest.getBatchType() != BatchedCommandRequest::BatchType_Insert || - origCmdRequest.isInsertIndexRequest()) - return NULL; + origCmdRequest.isInsertIndexRequest()) { + return nullptr; + } - unique_ptr<BatchedInsertRequest> idRequest; + std::unique_ptr<BatchedInsertRequest> idRequest; BatchedInsertRequest* origRequest = origCmdRequest.getInsertRequest(); - const vector<BSONObj>& inserts = origRequest->getDocuments(); + const std::vector<BSONObj>& inserts = origRequest->getDocuments(); size_t i = 0u; - for (vector<BSONObj>::const_iterator it = inserts.begin(); it != inserts.end(); ++it, ++i) { + for (auto it = inserts.begin(); it != inserts.end(); ++it, ++i) { const BSONObj& insert = *it; BSONObj idInsert; @@ -344,7 +314,7 @@ BatchedCommandRequest* BatchedCommandRequest::cloneWithIds( idInsert = idInsertB.obj(); } - if (NULL == idRequest.get() && !idInsert.isEmpty()) { + if (!idRequest && !idInsert.isEmpty()) { idRequest.reset(new BatchedInsertRequest); origRequest->cloneTo(idRequest.get()); } @@ -354,24 +324,25 @@ BatchedCommandRequest* BatchedCommandRequest::cloneWithIds( } } - if (NULL == idRequest.get()) - return NULL; + if (!idRequest) { + return nullptr; + } // Command request owns idRequest return new BatchedCommandRequest(idRequest.release()); } bool BatchedCommandRequest::containsNoIDUpsert(const BatchedCommandRequest& request) { - if (request.getBatchType() != BatchedCommandRequest::BatchType_Update) + if (request.getBatchType() != BatchedCommandRequest::BatchType_Update) { return false; + } - const vector<BatchedUpdateDocument*>& updates = request.getUpdateRequest()->getUpdates(); + const auto& updates = request.getUpdateRequest()->getUpdates(); - for (vector<BatchedUpdateDocument*>::const_iterator it = updates.begin(); it != updates.end(); - ++it) { - const BatchedUpdateDocument* updateDoc = *it; - if (updateDoc->getUpsert() && updateDoc->getQuery()["_id"].eoo()) + for (const auto& updateDoc : updates) { + if (updateDoc->getUpsert() && updateDoc->getQuery()["_id"].eoo()) { return true; + } } return false; @@ -396,8 +367,8 @@ bool BatchedCommandRequest::containsUpserts(const BSONObj& writeCmdObj) { } bool BatchedCommandRequest::getIndexedNS(const BSONObj& writeCmdObj, - string* nsToIndex, - string* errMsg) { + std::string* nsToIndex, + std::string* errMsg) { BSONElement documentsEl = writeCmdObj[BatchedInsertRequest::documents()]; if (documentsEl.type() != Array) { *errMsg = "index write batch is invalid"; diff --git a/src/mongo/s/write_ops/batched_command_request.h b/src/mongo/s/write_ops/batched_command_request.h index a86c28f120d..a87e20df7b0 100644 --- a/src/mongo/s/write_ops/batched_command_request.h +++ b/src/mongo/s/write_ops/batched_command_request.h @@ -56,10 +56,6 @@ public: enum BatchType { BatchType_Insert, BatchType_Update, BatchType_Delete, BatchType_Unknown }; - // - // construction / destruction - // - BatchedCommandRequest(BatchType batchType); /** @@ -80,11 +76,6 @@ public: BatchedCommandRequest(BatchedDeleteRequest* deleteReq) : _batchType(BatchType_Delete), _deleteReq(deleteReq) {} - ~BatchedCommandRequest(){}; - - /** Copies all the fields present in 'this' to 'other'. */ - void cloneTo(BatchedCommandRequest* other) const; - bool isValid(std::string* errMsg) const; BSONObj toBSON() const; bool parseBSON(StringData dbName, const BSONObj& source, std::string* errMsg); @@ -95,14 +86,19 @@ public: // Batch type accessors // - BatchType getBatchType() const; + BatchType getBatchType() const { + return _batchType; + } + BatchedInsertRequest* getInsertRequest() const; BatchedUpdateRequest* getUpdateRequest() const; BatchedDeleteRequest* getDeleteRequest() const; + // Index creation is also an insert, but a weird one. bool isInsertIndexRequest() const; bool isUniqueIndexRequest() const; bool isValidIndexRequest(std::string* errMsg) const; + std::string getTargetingNS() const; const NamespaceString& getTargetingNSS() const; BSONObj getIndexKeyPattern() const; diff --git a/src/mongo/s/write_ops/batched_command_response.cpp b/src/mongo/s/write_ops/batched_command_response.cpp index 9a835a1cf3f..5e949afa3ae 100644 --- a/src/mongo/s/write_ops/batched_command_response.cpp +++ b/src/mongo/s/write_ops/batched_command_response.cpp @@ -58,11 +58,6 @@ BatchedCommandResponse::BatchedCommandResponse() { clear(); } -BatchedCommandResponse::~BatchedCommandResponse() { - unsetErrDetails(); - unsetUpsertDetails(); -} - bool BatchedCommandResponse::isValid(std::string* errMsg) const { std::string dummy; if (errMsg == NULL) { diff --git a/src/mongo/s/write_ops/batched_command_response.h b/src/mongo/s/write_ops/batched_command_response.h index 3f0fef9491f..0789d3cf2d7 100644 --- a/src/mongo/s/write_ops/batched_command_response.h +++ b/src/mongo/s/write_ops/batched_command_response.h @@ -31,11 +31,11 @@ #include <string> #include <vector> +#include "mongo/base/disallow_copying.h" #include "mongo/base/string_data.h" #include "mongo/db/jsobj.h" #include "mongo/db/repl/optime.h" #include "mongo/rpc/write_concern_error_detail.h" -#include "mongo/s/bson_serializable.h" #include "mongo/s/write_ops/batched_upsert_detail.h" #include "mongo/s/write_ops/write_error_detail.h" @@ -45,7 +45,8 @@ namespace mongo { * This class represents the layout and content of a insert/update/delete runCommand, * the response side. */ -class BatchedCommandResponse : public BSONSerializable { +class BatchedCommandResponse { + MONGO_DISALLOW_COPYING(BatchedCommandResponse); public: // @@ -62,32 +63,18 @@ public: static const BSONField<std::vector<WriteErrorDetail*>> writeErrors; static const BSONField<WriteConcernErrorDetail*> writeConcernError; - // - // construction / destruction - // - BatchedCommandResponse(); - virtual ~BatchedCommandResponse(); - - // - // BatchedCommandResponse should have a move constructor but not a copy constructor - // - BatchedCommandResponse(BatchedCommandResponse&&) = default; BatchedCommandResponse& operator=(BatchedCommandResponse&&) = default; /** Copies all the fields present in 'this' to 'other'. */ void cloneTo(BatchedCommandResponse* other) const; - // - // bson serializable interface implementation - // - - virtual bool isValid(std::string* errMsg) const; - virtual BSONObj toBSON() const; - virtual bool parseBSON(const BSONObj& source, std::string* errMsg); - virtual void clear(); - virtual std::string toString() const; + bool isValid(std::string* errMsg) const; + BSONObj toBSON() const; + bool parseBSON(const BSONObj& source, std::string* errMsg); + void clear(); + std::string toString() const; // // individual field accessors diff --git a/src/mongo/s/write_ops/batched_delete_document.cpp b/src/mongo/s/write_ops/batched_delete_document.cpp index 0e6b94722c8..e5e5f02ef7f 100644 --- a/src/mongo/s/write_ops/batched_delete_document.cpp +++ b/src/mongo/s/write_ops/batched_delete_document.cpp @@ -44,8 +44,6 @@ BatchedDeleteDocument::BatchedDeleteDocument() { clear(); } -BatchedDeleteDocument::~BatchedDeleteDocument() {} - bool BatchedDeleteDocument::isValid(std::string* errMsg) const { std::string dummy; if (errMsg == NULL) { diff --git a/src/mongo/s/write_ops/batched_delete_document.h b/src/mongo/s/write_ops/batched_delete_document.h index 9805c1cc81a..acb0bbd4b8e 100644 --- a/src/mongo/s/write_ops/batched_delete_document.h +++ b/src/mongo/s/write_ops/batched_delete_document.h @@ -31,9 +31,9 @@ #include <string> #include <vector> +#include "mongo/base/disallow_copying.h" #include "mongo/base/string_data.h" #include "mongo/db/jsobj.h" -#include "mongo/s/bson_serializable.h" namespace mongo { @@ -41,7 +41,7 @@ namespace mongo { * This class represents the layout and content of a delete document runCommand, * in the resquest side. */ -class BatchedDeleteDocument : public BSONSerializable { +class BatchedDeleteDocument { MONGO_DISALLOW_COPYING(BatchedDeleteDocument); public: @@ -53,29 +53,16 @@ public: static const BSONField<int> limit; static const BSONField<BSONObj> collation; - // - // construction / destruction - // - BatchedDeleteDocument(); - virtual ~BatchedDeleteDocument(); /** Copies all the fields present in 'this' to 'other'. */ void cloneTo(BatchedDeleteDocument* other) const; - // - // bson serializable interface implementation - // - - virtual bool isValid(std::string* errMsg) const; - virtual BSONObj toBSON() const; - virtual bool parseBSON(const BSONObj& source, std::string* errMsg); - virtual void clear(); - virtual std::string toString() const; - - // - // individual field accessors - // + bool isValid(std::string* errMsg) const; + BSONObj toBSON() const; + bool parseBSON(const BSONObj& source, std::string* errMsg); + void clear(); + std::string toString() const; void setQuery(const BSONObj& query); void unsetQuery(); diff --git a/src/mongo/s/write_ops/batched_update_document.cpp b/src/mongo/s/write_ops/batched_update_document.cpp index 5fee8077ff7..a98dcb30908 100644 --- a/src/mongo/s/write_ops/batched_update_document.cpp +++ b/src/mongo/s/write_ops/batched_update_document.cpp @@ -48,8 +48,6 @@ BatchedUpdateDocument::BatchedUpdateDocument() { clear(); } -BatchedUpdateDocument::~BatchedUpdateDocument() {} - bool BatchedUpdateDocument::isValid(std::string* errMsg) const { std::string dummy; if (errMsg == NULL) { diff --git a/src/mongo/s/write_ops/batched_update_document.h b/src/mongo/s/write_ops/batched_update_document.h index 28adc50f650..749dbe5a384 100644 --- a/src/mongo/s/write_ops/batched_update_document.h +++ b/src/mongo/s/write_ops/batched_update_document.h @@ -31,9 +31,9 @@ #include <string> #include <vector> +#include "mongo/base/disallow_copying.h" #include "mongo/base/string_data.h" #include "mongo/db/jsobj.h" -#include "mongo/s/bson_serializable.h" namespace mongo { @@ -41,7 +41,7 @@ namespace mongo { * This class represents the layout and content of a update document runCommand, * in the request side. */ -class BatchedUpdateDocument : public BSONSerializable { +class BatchedUpdateDocument { MONGO_DISALLOW_COPYING(BatchedUpdateDocument); public: @@ -56,12 +56,7 @@ public: static const BSONField<BSONObj> collation; static const BSONField<BSONArray> arrayFilters; - // - // construction / destruction - // - BatchedUpdateDocument(); - virtual ~BatchedUpdateDocument(); /** Copies all the fields present in 'this' to 'other'. */ void cloneTo(BatchedUpdateDocument* other) const; @@ -70,15 +65,11 @@ public: // bson serializable interface implementation // - virtual bool isValid(std::string* errMsg) const; - virtual BSONObj toBSON() const; - virtual bool parseBSON(const BSONObj& source, std::string* errMsg); - virtual void clear(); - virtual std::string toString() const; - - // - // individual field accessors - // + bool isValid(std::string* errMsg) const; + BSONObj toBSON() const; + bool parseBSON(const BSONObj& source, std::string* errMsg); + void clear(); + std::string toString() const; void setQuery(const BSONObj& query); void unsetQuery(); |