summaryrefslogtreecommitdiff
path: root/src/mongo/db/collection_index_usage_tracker.h
diff options
context:
space:
mode:
authorJames Wahlin <james.wahlin@10gen.com>2015-09-30 17:41:56 -0400
committerJames Wahlin <james.wahlin@10gen.com>2015-10-07 15:42:22 -0400
commitec97a61067e2dc3f9c4e58a9d66b5e1f2600f978 (patch)
tree40c67ec652a87b17b794a8ba5fc5aa3b4fc3e99e /src/mongo/db/collection_index_usage_tracker.h
parent33167b814bb9d8962205a85fed34c9d88942db83 (diff)
downloadmongo-ec97a61067e2dc3f9c4e58a9d66b5e1f2600f978.tar.gz
SERVER-20520 Include index key in $indexStats return documents
Diffstat (limited to 'src/mongo/db/collection_index_usage_tracker.h')
-rw-r--r--src/mongo/db/collection_index_usage_tracker.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/db/collection_index_usage_tracker.h b/src/mongo/db/collection_index_usage_tracker.h
index def45712aad..ad55c229972 100644
--- a/src/mongo/db/collection_index_usage_tracker.h
+++ b/src/mongo/db/collection_index_usage_tracker.h
@@ -30,6 +30,7 @@
#include "mongo/base/disallow_copying.h"
#include "mongo/base/string_data.h"
+#include "mongo/bson/bsonobj.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/util/string_map.h"
#include "mongo/util/time_support.h"
@@ -51,14 +52,18 @@ class CollectionIndexUsageTracker {
public:
struct IndexUsageStats {
IndexUsageStats() = default;
- explicit IndexUsageStats(Date_t now) : trackerStartTime(now) {}
+ explicit IndexUsageStats(Date_t now, const BSONObj& key)
+ : trackerStartTime(now), indexKey(key.getOwned()) {}
IndexUsageStats(const IndexUsageStats& other)
- : accesses(other.accesses.load()), trackerStartTime(other.trackerStartTime) {}
+ : accesses(other.accesses.load()),
+ trackerStartTime(other.trackerStartTime),
+ indexKey(other.indexKey) {}
IndexUsageStats& operator=(const IndexUsageStats& other) {
accesses.store(other.accesses.load());
trackerStartTime = other.trackerStartTime;
+ indexKey = other.indexKey;
return *this;
}
@@ -67,6 +72,9 @@ public:
// Date/Time that we started tracking index usage.
Date_t trackerStartTime;
+
+ // An owned copy of the associated IndexDescriptor's index key.
+ BSONObj indexKey;
};
/**
@@ -87,7 +95,7 @@ public:
* Add map entry for 'indexName' stats collection. Must be called under exclusive collection
* lock.
*/
- void registerIndex(StringData indexName);
+ void registerIndex(StringData indexName, const BSONObj& indexKey);
/**
* Erase statistics for index 'indexName'. Must be called under exclusive collection lock.