[GODRIVER-610] Scope & Design Improved BSON Support Created: 24/Oct/18  Updated: 21/Dec/18  Resolved: 14/Nov/18

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: 0.0.18

Type: Improvement Priority: Major - P3
Reporter: Kristofer Brandow (Inactive) Assignee: Kristofer Brandow (Inactive)
Resolution: Done Votes: 0
Labels: beta
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by GODRIVER-413 Implement Improved BSON Design Closed
is depended on by GODRIVER-634 Add benchmarks for D, Doc, and Raw BS... Closed
Related
is related to GODRIVER-632 Add As* methods to bsoncore.Value, bs... Closed

 Description   

After receiving feedback on the BSON library, a new design for several components is required. This design should encompass the needs of users migrating from the community driver, users who need a high performance BSON implementation, and those who work with BSON directly but do not require a low level interface.



 Comments   
Comment by Kristofer Brandow (Inactive) [ 14/Nov/18 ]

Code Reviews: https://review.gerrithub.io/c/mongodb/mongo-go-driver/+/431549 and https://review.gerrithub.io/c/mongodb/mongo-go-driver/+/433195.

Comment by Githook User [ 14/Nov/18 ]

Author:

{'name': 'Kris Brandow', 'email': 'kris@mongodb.com', 'username': 'skriptble'}

Message: Redesign Document, Array, Element, and Value types

Migration Notes:
The Document, Element, Value, and Array types have been redesign and
rewritten. They have been renamed Doc, Elem, Val, and Arr respectively.
And additional type, MDoc, has been created.

The Value type no longer stores values as a slice of bytes,
instead opting for a compact 32byte representation that stores values
closer to native Go types. An empty Value is equivalent to a BSON Null.
All of the methods in this package will treat Value{} and
bson.Null() as the same.

The Element type is much simpler and adds a key to a Value.

The Document and Array types have been simplified, removing many of
their methods, and making them conceptually two different types, instead
of building an Array on top of a Document. Their methods have also been
updated to handle easier usage of Element and Value instances.

The constructors have been removed and replaced with a simpler
construction system that uses functions. There is a symmetry between
these functions and the methods on the Value type. The input to the
constructor matches the output of the Value method, for example this is
valid: bson.Double(val.Double()).

The BSON primitive types have been moved from the bson package to a new
package called primitive. The types that were (briefly) called
Primitive are now call primitive., e.g.
RegexPrimitive->primitive.Regex.

The Doc and MDoc types are functionally equivalents of D and M, but with
much higher type safety. Because Doc, MDoc, Arr, Elem, and Val form a
closed systems, and because it's not possible to create an invalid Val
type, Doc, MDoc, and Arr never return errors when Marshaling to BSON.
Both Doc and MDoc have depth traversal capabilities, so looking up a key
thats several subdocuments deep can be done with a single method call,
and in the case of MDoc can be done so in a higher performance manner.

When migrating from Document to Doc, users should ensure they reassign
the return of Append, Prepend, and Set to the doc. With Document, one
could call Append and it would modify the original document, the new Doc
type does not operate in this manner and operates similar to a regular
slice.

GODRIVER-413
GODRIVER-610

Change-Id: I353a83b7c8f8c5fa0c2552de9ff8bc78d55c50bc
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/bc03cee70acb5c99b3eabea12b3e3cfe2e6f3232

Comment by Ian Whalen (Inactive) [ 09/Nov/18 ]

2018-11-09: target date of 2018-11-23 (2 weeks)

Generated at Thu Feb 08 08:34:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.