summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/process_interface/mongo_process_interface.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/process_interface/mongo_process_interface.h')
-rw-r--r--src/mongo/db/pipeline/process_interface/mongo_process_interface.h63
1 files changed, 47 insertions, 16 deletions
diff --git a/src/mongo/db/pipeline/process_interface/mongo_process_interface.h b/src/mongo/db/pipeline/process_interface/mongo_process_interface.h
index 19477adf8c9..5ee0e401924 100644
--- a/src/mongo/db/pipeline/process_interface/mongo_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/mongo_process_interface.h
@@ -78,7 +78,7 @@ class MongoProcessInterface {
public:
/**
* Storage for a batch of BSON Objects to be updated in the write namespace. For each element
- * in the batch we store a tuple of the folliwng elements:
+ * in the batch we store a tuple of the following elements:
* 1. BSONObj - specifies the query that identifies a document in the to collection to be
* updated.
* 2. write_ops::UpdateModification - either the new document we want to upsert or insert into
@@ -106,6 +106,30 @@ public:
enum class CurrentOpBacktraceMode { kIncludeBacktrace, kExcludeBacktrace };
/**
+ * Interface which estimates the size of a given write operation.
+ */
+ class WriteSizeEstimator {
+ public:
+ virtual ~WriteSizeEstimator() = default;
+
+ /**
+ * Set of functions which estimate the entire size of a write command except for the array
+ * of write statements themselves.
+ */
+ virtual int estimateInsertHeaderSize(
+ const write_ops::InsertCommandRequest& insertReq) const = 0;
+ virtual int estimateUpdateHeaderSize(
+ const write_ops::UpdateCommandRequest& updateReq) const = 0;
+
+ /**
+ * Set of functions which estimate the size of a single write statement.
+ */
+ virtual int estimateInsertSizeBytes(const BSONObj& insert) const = 0;
+ virtual int estimateUpdateSizeBytes(const BatchObject& batchObject,
+ UpsertType type) const = 0;
+ };
+
+ /**
* Factory function to create MongoProcessInterface of the right type. The implementation will
* be installed by a lib higher up in the link graph depending on the application type.
*/
@@ -127,6 +151,12 @@ public:
virtual ~MongoProcessInterface(){};
/**
+ * Returns an instance of a 'WriteSizeEstimator' interface.
+ */
+ virtual std::unique_ptr<WriteSizeEstimator> getWriteSizeEstimator(
+ OperationContext* opCtx, const NamespaceString& ns) const = 0;
+
+ /**
* Creates a new TransactionHistoryIterator object. Only applicable in processes which support
* locally traversing the oplog.
*/
@@ -149,29 +179,30 @@ public:
virtual void updateClientOperationTime(OperationContext* opCtx) const = 0;
/**
- * Inserts 'objs' into 'ns' and returns an error Status if the insert fails. If 'targetEpoch' is
- * set, throws ErrorCodes::StaleEpoch if the targeted collection does not have the same epoch or
- * the epoch changes during the course of the insert.
+ * Executes 'insertCommand' against 'ns' and returns an error Status if the insert fails. If
+ * 'targetEpoch' is set, throws ErrorCodes::StaleEpoch if the targeted collection does not have
+ * the same epoch or the epoch changes during the course of the insert.
*/
virtual Status insert(const boost::intrusive_ptr<ExpressionContext>& expCtx,
const NamespaceString& ns,
- std::vector<BSONObj>&& objs,
+ std::unique_ptr<write_ops::InsertCommandRequest> insertCommand,
const WriteConcernOptions& wc,
boost::optional<OID> targetEpoch) = 0;
/**
- * Updates the documents matching 'queries' with the objects 'updates'. Returns an error Status
- * if any of the updates fail, otherwise returns an 'UpdateResult' objects with the details of
- * the update operation. If 'targetEpoch' is set, throws ErrorCodes::StaleEpoch if the targeted
- * collection does not have the same epoch, or if the epoch changes during the update.
+ * Executes the updates described by 'updateCommand'. Returns an error Status if any of the
+ * updates fail, otherwise returns an 'UpdateResult' objects with the details of the update
+ * operation. If 'targetEpoch' is set, throws ErrorCodes::StaleEpoch if the targeted collection
+ * does not have the same epoch, or if the epoch changes during the update.
*/
- virtual StatusWith<UpdateResult> update(const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const NamespaceString& ns,
- BatchedObjects&& batch,
- const WriteConcernOptions& wc,
- UpsertType upsert,
- bool multi,
- boost::optional<OID> targetEpoch) = 0;
+ virtual StatusWith<UpdateResult> update(
+ const boost::intrusive_ptr<ExpressionContext>& expCtx,
+ const NamespaceString& ns,
+ std::unique_ptr<write_ops::UpdateCommandRequest> updateCommand,
+ const WriteConcernOptions& wc,
+ UpsertType upsert,
+ bool multi,
+ boost::optional<OID> targetEpoch) = 0;
/**
* Returns index usage statistics for each index on collection 'ns' along with additional