diff options
author | James Wahlin <james.wahlin@10gen.com> | 2016-04-05 09:33:23 -0400 |
---|---|---|
committer | James Wahlin <james.wahlin@10gen.com> | 2016-04-21 11:45:40 -0400 |
commit | 6bbaee174447ee1c9177c72bdd07f050ab07e901 (patch) | |
tree | 213a1b76b23f31c143fb8ac4f3299fb1e13fc8a9 /src/mongo/db/index | |
parent | 223c2a1aa5fd11fd3e7115ca9acb6d1217f80f92 (diff) | |
download | mongo-6bbaee174447ee1c9177c72bdd07f050ab07e901.tar.gz |
SERVER-23271 Add keysInserted and keysDeleted metrics for CRUD ops
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 17 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.h | 14 |
2 files changed, 23 insertions, 8 deletions
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index f99d3104c30..b10bc6add71 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -102,8 +102,8 @@ Status IndexAccessMethod::insert(OperationContext* txn, const RecordId& loc, const InsertDeleteOptions& options, int64_t* numInserted) { + invariant(numInserted); *numInserted = 0; - BSONObjSet keys; // Delegate to the subclass. getKeys(obj, &keys); @@ -179,9 +179,10 @@ Status IndexAccessMethod::remove(OperationContext* txn, const RecordId& loc, const InsertDeleteOptions& options, int64_t* numDeleted) { + invariant(numDeleted); + *numDeleted = 0; BSONObjSet keys; getKeys(obj, &keys); - *numDeleted = 0; for (BSONObjSet::const_iterator i = keys.begin(); i != keys.end(); ++i) { removeOneKey(txn, *i, loc, options.dupsAllowed); @@ -291,7 +292,14 @@ Status IndexAccessMethod::validateUpdate(OperationContext* txn, Status IndexAccessMethod::update(OperationContext* txn, const UpdateTicket& ticket, - int64_t* numUpdated) { + int64_t* numInserted, + int64_t* numDeleted) { + invariant(numInserted); + invariant(numDeleted); + + *numInserted = 0; + *numDeleted = 0; + if (!ticket._isValid) { return Status(ErrorCodes::InternalError, "Invalid UpdateTicket in update"); } @@ -317,7 +325,8 @@ Status IndexAccessMethod::update(OperationContext* txn, } } - *numUpdated = ticket.added.size(); + *numInserted = ticket.added.size(); + *numDeleted = ticket.removed.size(); return Status::OK(); } diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h index f0376af716a..1509500d916 100644 --- a/src/mongo/db/index/index_access_method.h +++ b/src/mongo/db/index/index_access_method.h @@ -71,7 +71,7 @@ public: /** * Internally generate the keys {k1, ..., kn} for 'obj'. For each key k, insert (k -> - * 'loc') into the index. 'obj' is the object at the location 'loc'. If not NULL, + * 'loc') into the index. 'obj' is the object at the location 'loc'. * 'numInserted' will be set to the number of keys added to the index for the document. If * there is more than one key for 'obj', either all keys will be inserted or none will. * @@ -84,8 +84,8 @@ public: int64_t* numInserted); /** - * Analogous to above, but remove the records instead of inserting them. If not NULL, - * numDeleted will be set to the number of keys removed from the index for the document. + * Analogous to above, but remove the records instead of inserting them. + * 'numDeleted' will be set to the number of keys removed from the index for the document. */ Status remove(OperationContext* txn, const BSONObj& obj, @@ -118,8 +118,14 @@ public: * 'from' will remain. Assumes that the index has not changed since validateUpdate was * called. If the index was changed, we may return an error, as our ticket may have been * invalidated. + * + * 'numInserted' will be set to the number of keys inserted into the index for the document. + * 'numDeleted' will be set to the number of keys removed from the index for the document. */ - Status update(OperationContext* txn, const UpdateTicket& ticket, int64_t* numUpdated); + Status update(OperationContext* txn, + const UpdateTicket& ticket, + int64_t* numInserted, + int64_t* numDeleted); /** * Returns an unpositioned cursor over 'this' index. |