summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/document.h')
-rw-r--r--src/mongo/db/pipeline/document.h34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/document.h b/src/mongo/db/pipeline/document.h
index 606db735c5c..fefbcbcdd67 100644
--- a/src/mongo/db/pipeline/document.h
+++ b/src/mongo/db/pipeline/document.h
@@ -271,8 +271,24 @@ public:
int memUsageForSorter() const {
return getApproximateSize();
}
- Document getOwned() const {
- return *this;
+
+ /**
+ * Returns a document that owns the underlying BSONObj.
+ */
+ Document getOwned() const;
+
+ /**
+ * Returns true if the underlying BSONObj is owned.
+ */
+ bool isOwned() const {
+ return _storage ? _storage->isOwned() : true;
+ }
+
+ /**
+ * Returns true if the document has been modified (i.e. it differs from the underlying BSONObj).
+ */
+ auto isModified() const {
+ return _storage ? _storage->isModified() : false;
}
/// only for testing
@@ -576,6 +592,20 @@ public:
return peek().getApproximateSize();
}
+ /**
+ * Returns true if the underlying BSONObj is owned.
+ */
+ bool isOwned() {
+ return storage().isOwned();
+ }
+
+ /**
+ * Takes the ownership of the underlying BSONObj if it is not owned.
+ */
+ void makeOwned() {
+ storage().makeOwned();
+ }
+
/** Create a new document storage with the BSON object.
*
* The optional paramater 'stripMetadata' controls whether we strip the metadata fields (the