summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2020-02-12 22:11:30 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-19 23:33:56 +0000
commit3e8b3ef099e6cfaeecae4e8fa1c8b5662d9bdaed (patch)
treef24d08c3a15084ad13924a3dff1c2f9b2387bddf /src/mongo/db/exec
parentd4877beab340f9991913ef28615fd24d90bdc036 (diff)
downloadmongo-3e8b3ef099e6cfaeecae4e8fa1c8b5662d9bdaed.tar.gz
SERVER-45418 Avoid explicitly batching documents in $cursor for count-like aggregates.
Diffstat (limited to 'src/mongo/db/exec')
-rw-r--r--src/mongo/db/exec/document_value/document.cpp5
-rw-r--r--src/mongo/db/exec/document_value/document.h13
2 files changed, 11 insertions, 7 deletions
diff --git a/src/mongo/db/exec/document_value/document.cpp b/src/mongo/db/exec/document_value/document.cpp
index 7400e88058d..d3b170368bc 100644
--- a/src/mongo/db/exec/document_value/document.cpp
+++ b/src/mongo/db/exec/document_value/document.cpp
@@ -594,10 +594,11 @@ const Value Document::getNestedField(const FieldPath& path, vector<Position>* po
}
size_t Document::getApproximateSize() const {
+ size_t size = sizeof(Document);
if (!_storage)
- return 0; // we've allocated no memory
+ return size;
- size_t size = sizeof(DocumentStorage);
+ size += sizeof(DocumentStorage);
size += storage().allocatedBytes();
for (auto it = storage().iteratorCacheOnly(); !it.atEnd(); it.advance()) {
diff --git a/src/mongo/db/exec/document_value/document.h b/src/mongo/db/exec/document_value/document.h
index 978d008cae0..a4be77a09e8 100644
--- a/src/mongo/db/exec/document_value/document.h
+++ b/src/mongo/db/exec/document_value/document.h
@@ -188,12 +188,15 @@ public:
/// Convenience type for dealing with fields. Used by FieldIterator.
typedef std::pair<StringData, Value> FieldPair;
- /** Get the approximate storage size of the document and sub-values in bytes.
- * Note: Some memory may be shared with other Documents or between fields within
- * a single Document so this can overestimate usage.
+ /**
+ * Get the approximate size of the Document, plus its underlying storage and sub-values. Returns
+ * size in bytes.
+ *
+ * Note: Some memory may be shared with other Documents or between fields within a single
+ * Document so this can overestimate usage.
*
- * Note: the value returned by this function includes the size of the metadata associated with
- * the document.
+ * Note: the value returned by this function includes the size of the metadata associated with
+ * the document.
*/
size_t getApproximateSize() const;