MongoDB C++ Driver legacy-1.0.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
mongo::WriteOperation Class Referenceabstract

Represents a single server side write operation and encapsulates the process for encoding the operation into either a wire protocol request message or a command. More...

#include <write_operation.h>

+ Inheritance diagram for mongo::WriteOperation:

Public Member Functions

virtual WriteOpType operationType () const =0
 Returns the MongoDB wire protocol operation type represented by an instance of this particular write operation.
 
virtual const char * batchName () const =0
 Returns the name for a batch of this type of write operation.
 
virtual int incrementalSize () const =0
 Returns the incremental size (in bytes) required to add this write operation to a batch.
 
virtual void startRequest (const std::string &ns, bool ordered, BufBuilder *builder) const =0
 Appends the preamble for a wire protocol message into the supplied BufBuilder.
 
virtual void appendSelfToRequest (BufBuilder *builder) const =0
 Appends a document (or documents in the case of update) which describe the write operation represented by an instance of this class into the supplied BufBuilder.
 
virtual void startCommand (const std::string &ns, BSONObjBuilder *command) const =0
 Appends the preamble for a write command into the supplied BSONObjBuilder.
 
virtual void appendSelfToCommand (BSONArrayBuilder *batch) const =0
 Appends a single document that describes the write operation represented by an instance of this class into the supplied BSONArrayBuilder.
 
virtual void appendSelfToBSONObj (BSONObjBuilder *obj) const =0
 Appends the data represented by an instance of this class to a BSONObjBuilder.
 
virtual void setBulkIndex (size_t index)=0
 Sets the index of this WriteOperation in the context of a larger bulk operation.
 
virtual size_t getBulkIndex () const =0
 The index of this WriteOperation in the context of a larger bulk operation.
 

Detailed Description

Represents a single server side write operation and encapsulates the process for encoding the operation into either a wire protocol request message or a command.

Member Function Documentation

◆ appendSelfToCommand()

virtual void mongo::WriteOperation::appendSelfToCommand ( BSONArrayBuilder batch) const
pure virtual

Appends a single document that describes the write operation represented by an instance of this class into the supplied BSONArrayBuilder.

This method will be called multiple times by a DBClientWriter in order to batch operations of the same type into a single command.

NOTE: The ultimate size of the of the command is bounded by the sever's maxBsonObjectSize.

Implemented in mongo::InsertWriteOperation, mongo::UpdateWriteOperation, and mongo::DeleteWriteOperation.

◆ appendSelfToRequest()

virtual void mongo::WriteOperation::appendSelfToRequest ( BufBuilder builder) const
pure virtual

Appends a document (or documents in the case of update) which describe the write operation represented by an instance of this class into the supplied BufBuilder.

This method may be called multiple times by a WireProtocolWriter in order to batch operations of the same type into a single wire protocol request.

NOTE: The size of this portion of the message is flexible but the size of the message itself is bounded by the server's maxMessageSizeBytes.

Implemented in mongo::DeleteWriteOperation, mongo::InsertWriteOperation, and mongo::UpdateWriteOperation.

◆ startCommand()

virtual void mongo::WriteOperation::startCommand ( const std::string &  ns,
BSONObjBuilder command 
) const
pure virtual

Appends the preamble for a write command into the supplied BSONObjBuilder.

Typically this involves a single bson element having a key that represents the operation type and a value which represents the collection to which the operation will be applied. This write op element must be the first element in the document according to the specification.

Implemented in mongo::DeleteWriteOperation, mongo::InsertWriteOperation, and mongo::UpdateWriteOperation.

◆ startRequest()

virtual void mongo::WriteOperation::startRequest ( const std::string &  ns,
bool  ordered,
BufBuilder builder 
) const
pure virtual

Appends the preamble for a wire protocol message into the supplied BufBuilder.

This is the part of the wire protocol message after the header but before the bson document portion. It typically contains the namespace, flags, and potentially space reserved by the protocol for future use.

NOTE: The size of the preamble is fixed but operation type dependant.

Implemented in mongo::DeleteWriteOperation, mongo::InsertWriteOperation, and mongo::UpdateWriteOperation.


The documentation for this class was generated from the following file: