-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Internal Code, Write Ops
-
Fully Compatible
We currently only support in-place element updates for primitive types. In-place updates for complex types is tricky, because even if the new object or array has the same size as the existing object, its internal layout may differ.
That means that any Element objects that referred to regions of memory in the original layout would be invalidated once the damage vector was applied. Currently, the semantics of Document is that Elements are never invalidated.
We could either:
- State that you must abandon your Document after applying the damage vector to the supporting BSONObj, in which case we could simply enable support for in-place updates with object/array types right away, or:
- Restrict applying in-place updates to object/array types to the case where the object or array to be updated in-place has opaque children, meaning that we had never formed any Element objects that referred into that region of memory, meaning that no Elements would be invalidated by the update.